Bladeren bron

修改bug

zhoufan 7 jaren geleden
bovenliggende
commit
c897f0e4c7
1 gewijzigde bestanden met toevoegingen van 20 en 31 verwijderingen
  1. 20 31
      CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

+ 20 - 31
CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

@@ -874,40 +874,29 @@ namespace CallCenter.Utility
874 874
 
875 875
                 sheet.AddMergedRegion(new CellRangeAddress(15, 15, 0, 7));
876 876
 
877
-                IRow irow16 = sheet.CreateRow(16);
878
-                IRow irow17 = sheet.CreateRow(17);
879
-                IRow irow18 = sheet.CreateRow(18);
880
-                int l = 0;
881
-                foreach (DataRow dr5 in dt5.Rows)
877
+                int rowcount = (dt5.Rows.Count / 4) + 1;
878
+
879
+                for (int i = 0; i < rowcount; i++)
882 880
                 {
883
-                    if (l < 4)
884
-                    {
885
-                        ICell cell161 = irow16.CreateCell(2 * (l + 1) - 2);
886
-                        cell161.SetCellValue(dr5["areaname"].ToString());
887
-                        cell161.CellStyle = cellStyle;
888
-                        ICell cell162 = irow16.CreateCell(2 * (l + 1) - 1);
889
-                        cell162.SetCellValue(Int32.Parse(dr5["count"].ToString()));
890
-                        cell162.CellStyle = cellStyle;
891
-                    }
892
-                    else if (l < 8 && l >= 4)
893
-                    {
894
-                        ICell cell171 = irow17.CreateCell(2 * (l - 3) - 2);
895
-                        cell171.SetCellValue(dr5["areaname"].ToString());
896
-                        cell171.CellStyle = cellStyle;
897
-                        ICell cell172 = irow17.CreateCell(2 * (l - 3) - 1);
898
-                        cell172.SetCellValue(Int32.Parse(dr5["count"].ToString()));
899
-                        cell172.CellStyle = cellStyle;
900
-                    }
901
-                    else
881
+                    IRow irow = sheet.CreateRow(16 + i);
882
+                    for (int j = 0; j < 4; j++)
902 883
                     {
903
-                        ICell cell181 = irow18.CreateCell(2 * (l - 7) - 2);
904
-                        cell181.SetCellValue(dr5["areaname"].ToString());
905
-                        cell181.CellStyle = cellStyle;
906
-                        ICell cell182 = irow18.CreateCell(2 * (l - 7) - 1);
907
-                        cell182.SetCellValue(Int32.Parse(dr5["count"].ToString()));
908
-                        cell182.CellStyle = cellStyle;
884
+                        int num = i * 4 + j;
885
+                        if (num != dt5.Rows.Count)
886
+                        {
887
+                            var dr = dt5.Rows[num];
888
+                            ICell cellname = irow.CreateCell(2 * (j + 1) - 2);
889
+                            cellname.SetCellValue(dr["areaname"].ToString());
890
+                            cellname.CellStyle = cellStyle;
891
+                            ICell cellcount = irow.CreateCell(2 * (j + 1) - 1);
892
+                            cellcount.SetCellValue(Int32.Parse(dr["count"].ToString()));
893
+                            cellcount.CellStyle = cellStyle;
894
+                        }
895
+                        else
896
+                        {
897
+                            break;
898
+                        }
909 899
                     }
910
-                    l = l + 1;
911 900
                 }
912 901
 
913 902
                 #endregion