|
|
@@ -783,6 +783,109 @@ namespace CallCenter.Utility
|
|
783
|
783
|
return "导出失败!";
|
|
784
|
784
|
}
|
|
785
|
785
|
}
|
|
|
786
|
+
|
|
|
787
|
+ /// <summary>
|
|
|
788
|
+ /// 督办数据报表导出
|
|
|
789
|
+ /// </summary>
|
|
|
790
|
+ /// <param name="ds"></param>
|
|
|
791
|
+ /// <returns></returns>
|
|
|
792
|
+ public string DBEJExportToExcel(DataTable dt, string Name, string month, string starttime, string endtime)
|
|
|
793
|
+ {
|
|
|
794
|
+ try
|
|
|
795
|
+ {
|
|
|
796
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
797
|
+ ISheet sheet = workbook.CreateSheet(Name);
|
|
|
798
|
+ ICellStyle cellStyle = workbook.CreateCellStyle();
|
|
|
799
|
+ NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
|
|
|
800
|
+ cellfont.Boldweight = (short)FontBoldWeight.Normal;
|
|
|
801
|
+ cellStyle.SetFont(cellfont);
|
|
|
802
|
+ ICellStyle cellStylebt = workbook.CreateCellStyle();
|
|
|
803
|
+ NPOI.SS.UserModel.IFont cellfontbt = workbook.CreateFont();
|
|
|
804
|
+ cellfontbt.Boldweight = (short)FontBoldWeight.Bold;
|
|
|
805
|
+ cellStylebt.SetFont(cellfontbt);
|
|
|
806
|
+ cellStylebt.VerticalAlignment = VerticalAlignment.Center;
|
|
|
807
|
+ cellStylebt.Alignment = HorizontalAlignment.Center;
|
|
|
808
|
+ IRow irow1 = sheet.CreateRow(0);
|
|
|
809
|
+ ICell cell1 = irow1.CreateCell(0);
|
|
|
810
|
+ cell1.SetCellValue("12345联动服务工作" + month + "月份办理情况通报表");
|
|
|
811
|
+ cell1.CellStyle = cellStylebt;
|
|
|
812
|
+ sheet.AddMergedRegion(new CellRangeAddress(0, 1, 0, 19));
|
|
|
813
|
+ IRow irow2 = sheet.CreateRow(2);
|
|
|
814
|
+ ICell cell2 = irow2.CreateCell(0);
|
|
|
815
|
+ cell2.SetCellValue("统计周期:" + starttime + "至" + endtime + " 统计时间:" + DateTime.Now.ToString("yyyy年MM月dd日"));
|
|
|
816
|
+ cell2.CellStyle = cellStylebt;
|
|
|
817
|
+ sheet.AddMergedRegion(new CellRangeAddress(2, 2, 0, 19));
|
|
|
818
|
+ IRow irow3 = sheet.CreateRow(3);
|
|
|
819
|
+ ICell cell3 = irow3.CreateCell(0);
|
|
|
820
|
+ cell3.SetCellValue("一、县(市、区)联动单位");
|
|
|
821
|
+ cell3.CellStyle = cellStylebt;
|
|
|
822
|
+ sheet.AddMergedRegion(new CellRangeAddress(3, 3, 0, 19));
|
|
|
823
|
+ string[] cols = {"序号","联动单位","承办件",
|
|
|
824
|
+ "承办率","得分(5分)","超期件","按时反馈率","得分(20分)",
|
|
|
825
|
+ "未果件","办结率","得分(10分)","退单件","有效回复率",
|
|
|
826
|
+ "得分(15分)","群众评议总数","一次不满意件","不满意件","满意率","得分(50分)","总分","排名"};
|
|
|
827
|
+ IRow irow4 = sheet.CreateRow(4);
|
|
|
828
|
+ int icolIndex = 0;
|
|
|
829
|
+ foreach (string dc in cols)
|
|
|
830
|
+ {
|
|
|
831
|
+ ICell cell = irow4.CreateCell(icolIndex);
|
|
|
832
|
+ cell.SetCellValue(dc);
|
|
|
833
|
+ cell.CellStyle = cellStylebt;
|
|
|
834
|
+ icolIndex++;
|
|
|
835
|
+ }
|
|
|
836
|
+ int iRowIndex = 5;
|
|
|
837
|
+ // DataRow[] rows = dt.Select("category=1");
|
|
|
838
|
+ int index = 0;
|
|
|
839
|
+ foreach (DataRow dr in dt.Rows )
|
|
|
840
|
+ {
|
|
|
841
|
+ index++;
|
|
|
842
|
+ int iCellIndex = 0;
|
|
|
843
|
+ IRow irow = sheet.CreateRow(iRowIndex);
|
|
|
844
|
+ for (int i = 0; i < 20; i++)
|
|
|
845
|
+ {
|
|
|
846
|
+ ICell cell = irow.CreateCell(iCellIndex);
|
|
|
847
|
+ cell.SetCellValue(GetCellValue(dr, index, i));
|
|
|
848
|
+ cell.CellStyle = cellStyle;
|
|
|
849
|
+ iCellIndex++;
|
|
|
850
|
+ }
|
|
|
851
|
+ iRowIndex++;
|
|
|
852
|
+ }
|
|
|
853
|
+ //自适应列宽度
|
|
|
854
|
+ for (int i = 0; i < 20; i++)
|
|
|
855
|
+ {
|
|
|
856
|
+ sheet.AutoSizeColumn(i);
|
|
|
857
|
+ // sheet.SetColumnWidth(i, 20 * 256);
|
|
|
858
|
+ }
|
|
|
859
|
+
|
|
|
860
|
+ using (MemoryStream ms = new MemoryStream())
|
|
|
861
|
+ {
|
|
|
862
|
+ workbook.Write(ms);
|
|
|
863
|
+
|
|
|
864
|
+ HttpContext curContext = HttpContext.Current;
|
|
|
865
|
+
|
|
|
866
|
+
|
|
|
867
|
+ // 设置编码和附件格式
|
|
|
868
|
+ curContext.Response.ContentType = "application/vnd.ms-excel";
|
|
|
869
|
+ curContext.Response.ContentEncoding = Encoding.UTF8;
|
|
|
870
|
+ curContext.Response.Charset = "";
|
|
|
871
|
+ curContext.Response.AppendHeader("Content-Disposition",
|
|
|
872
|
+ "attachment;filename=" + HttpUtility.UrlEncode(Name + ".xls", Encoding.UTF8));
|
|
|
873
|
+
|
|
|
874
|
+ curContext.Response.BinaryWrite(ms.GetBuffer());
|
|
|
875
|
+
|
|
|
876
|
+ workbook = null;
|
|
|
877
|
+ ms.Close();
|
|
|
878
|
+ ms.Dispose();
|
|
|
879
|
+
|
|
|
880
|
+ curContext.Response.End();
|
|
|
881
|
+ }
|
|
|
882
|
+ return "";
|
|
|
883
|
+ }
|
|
|
884
|
+ catch
|
|
|
885
|
+ {
|
|
|
886
|
+ return "导出失败!";
|
|
|
887
|
+ }
|
|
|
888
|
+ }
|
|
786
|
889
|
/// <summary>
|
|
787
|
890
|
/// 弹出下载框导出excel
|
|
788
|
891
|
/// </summary>
|