Browse Source

导出格式修改

callm 1 year ago
parent
commit
53d8d57add
1 changed files with 80 additions and 3 deletions
  1. 80 3
      UAS_MES_LGDZ/DataOperate/ExcelHandler.cs

+ 80 - 3
UAS_MES_LGDZ/DataOperate/ExcelHandler.cs

@@ -10,6 +10,8 @@ using NPOI.SS.Util;
 using System.Drawing;
 using System.Collections.Generic;
 using Seagull.BarTender.Print;
+using DevExpress.XtraPrinting.Native.LayoutAdjustment;
+using DevExpress.XtraExport.Implementation;
 
 namespace UAS_MES_NEW.DataOperate
 {
@@ -53,7 +55,8 @@ namespace UAS_MES_NEW.DataOperate
             return filePath;
         }
 
-        public MemoryStream DataTableToExcel_LIANGAN(DataTable DataTable,  string FolderPath) {
+        public MemoryStream DataTableToExcel_LIANGAN(DataTable DataTable, string FolderPath)
+        {
             //创建内存流
             MemoryStream ms = new MemoryStream();
             //创建一个Book,相当于一个Excel文件
@@ -65,16 +68,90 @@ namespace UAS_MES_NEW.DataOperate
             //设置列的宽度,根据首行的列的内容的长度来设置
             for (int i = 0; i < DataTable.Rows.Count; i++)
             {
-                if (DataTable.Rows[i]["STF_MACHINE"].ToString() != ""&&i!= DataTable.Rows.Count-1) {
+                if (DataTable.Rows[i]["STF_MACHINE"].ToString() != "" && i != DataTable.Rows.Count - 1)
+                {
                     Console.WriteLine(DataTable.Rows[i]["STF_MACHINE"].ToString());
-                    ISheet sheet1 = book.CreateSheet(DataTable.Rows[i]["STF_MACHINE"].ToString()+"-"+ DataTable.Rows[i + 1]["STF_MACHINE"].ToString().Substring(0,1));
+                    ISheet sheet1 = book.CreateSheet(DataTable.Rows[i]["STF_MACHINE"].ToString() + "-" + DataTable.Rows[i + 1]["STF_MACHINE"].ToString().Substring(0, 1));
                     IRow row1 = sheet1.CreateRow(0);
+                    row1.CreateCell(0); row1.Cells[0].SetCellValue("       SMT程式料表     ");
+                   
+                    //客户抬头
                     IRow row2 = sheet1.CreateRow(1);
+                    CellRangeAddress cellRangeAddress = new CellRangeAddress(1, 1, 0, 1);
+                    CellRangeAddress cellRangeAddress1 = new CellRangeAddress(1, 1, 2, 3);
+                    CellRangeAddress cellRangeAddress2 = new CellRangeAddress(1, 1, 4, 5);
+                    CellRangeAddress cellRangeAddress3 = new CellRangeAddress(1, 1, 6, 7);
+                    sheet1.AddMergedRegion(cellRangeAddress);
+                    sheet1.AddMergedRegion(cellRangeAddress1);
+                    sheet1.AddMergedRegion(cellRangeAddress2);
+                    sheet1.AddMergedRegion(cellRangeAddress3);
+                    row2.CreateCell(0); row2.CreateCell(1); row2.Cells[0].SetCellValue("客户名称:");
+                    row2.CreateCell(2); row2.CreateCell(3); row2.Cells[2].SetCellValue("CY");
+                    row2.CreateCell(4); row2.CreateCell(5); row2.Cells[4].SetCellValue("文件编号://");
+                    row2.CreateCell(6); row2.CreateCell(7); row2.Cells[6].SetCellValue("发行日期:2024-06-14");
+                   
+                    //产品型号
                     IRow row3 = sheet1.CreateRow(2);
+                    CellRangeAddress cellRangeAddress4 = new CellRangeAddress(2, 2, 0, 1);
+                    CellRangeAddress cellRangeAddress5 = new CellRangeAddress(2, 2, 2, 3);
+                    CellRangeAddress cellRangeAddress6 = new CellRangeAddress(2, 2, 4, 5);
+                    CellRangeAddress cellRangeAddress7 = new CellRangeAddress(2, 2, 6, 7);
+                    sheet1.AddMergedRegion(cellRangeAddress4);
+                    sheet1.AddMergedRegion(cellRangeAddress5);
+                    sheet1.AddMergedRegion(cellRangeAddress6);
+                    sheet1.AddMergedRegion(cellRangeAddress7);
+                    row3.CreateCell(0); row3.CreateCell(1); row3.Cells[0].SetCellValue("产品型号:");
+                    row3.CreateCell(2); row3.CreateCell(3); row3.Cells[2].SetCellValue("it9220-LS2404-B1-V2.0-MB");
+                    row3.CreateCell(4); row3.CreateCell(5); row3.Cells[4].SetCellValue("BOM编号:EN-CY-BOM-143(A0)");
+                    row3.CreateCell(6); row3.CreateCell(7); row3.Cells[6].SetCellValue("生效日期:2024-06-14");
+                    
+                    //程序名称
                     IRow row4 = sheet1.CreateRow(3);
+                    CellRangeAddress cellRangeAddress8 = new CellRangeAddress(3, 3, 0, 1);
+                    CellRangeAddress cellRangeAddress9 = new CellRangeAddress(3, 3, 2, 3);
+                    CellRangeAddress cellRangeAddress10 = new CellRangeAddress(3, 3, 4, 5);
+                    sheet1.AddMergedRegion(cellRangeAddress8);
+                    sheet1.AddMergedRegion(cellRangeAddress9);
+                    sheet1.AddMergedRegion(cellRangeAddress10);
+                    row4.CreateCell(0); row4.CreateCell(1); row4.Cells[0].SetCellValue("程序名称\t\r\n");
+                    row4.CreateCell(2); row4.CreateCell(3); row4.Cells[2].SetCellValue("CY-it9220-LS2404-B1-V2.0-MB\t\r\n");
+                    row4.CreateCell(4); row4.CreateCell(5); row4.Cells[4].SetCellValue("面别:    AB面\t\r\n");
+
+                    //机器名称
                     IRow row5 = sheet1.CreateRow(4);
+                    CellRangeAddress cellRangeAddress14 = new CellRangeAddress(5, 5, 0, 1);
+                    CellRangeAddress cellRangeAddress15 = new CellRangeAddress(5, 5, 2, 3);
+                    CellRangeAddress cellRangeAddress16 = new CellRangeAddress(5, 5, 4, 5);
+                    CellRangeAddress cellRangeAddress20 = new CellRangeAddress(5, 6, 6, 7);
+                    sheet1.AddMergedRegion(cellRangeAddress20);
+                    sheet1.AddMergedRegion(cellRangeAddress14);
+                    sheet1.AddMergedRegion(cellRangeAddress15);
+                    sheet1.AddMergedRegion(cellRangeAddress16);
+                    sheet1.AddMergedRegion(cellRangeAddress20);
+                    row5.CreateCell(0); row5.CreateCell(1); row5.Cells[0].SetCellValue("机器名称\t\r\n");
+                    row5.CreateCell(2); row5.CreateCell(3); row5.Cells[2].SetCellValue("TX2I+TX2I+TX2I+TX2+SX1\t\r\n");
+                    row5.CreateCell(4); row5.CreateCell(5); row5.Cells[4].SetCellValue("QA确认:\t\r\n");
+                    row5.CreateCell(6); row5.CreateCell(7); row5.Cells[6].SetCellValue("文控签章:");
+
+                    //制作
                     IRow row6 = sheet1.CreateRow(5);
+                    CellRangeAddress cellRangeAddress17 = new CellRangeAddress(6, 6, 0, 1);
+                    CellRangeAddress cellRangeAddress18 = new CellRangeAddress(6, 6, 2, 3);
+                    CellRangeAddress cellRangeAddress19 = new CellRangeAddress(6, 6, 4, 5);
+                    sheet1.AddMergedRegion(cellRangeAddress17);
+                    sheet1.AddMergedRegion(cellRangeAddress18);
+                    sheet1.AddMergedRegion(cellRangeAddress19);
+                    row6.CreateCell(0); row6.CreateCell(1); row6.Cells[0].SetCellValue("制作:"    );
+                    row6.CreateCell(2); row6.CreateCell(3); row6.Cells[2].SetCellValue("贺瑞华");
+                    row6.CreateCell(4); row6.CreateCell(5); row6.Cells[4].SetCellValue("QA审核:");
+
+                    //制作
                     IRow row7 = sheet1.CreateRow(6);
+                    CellRangeAddress cellRangeAddress21 = new CellRangeAddress(6, 6, 0, 7);
+                    sheet1.AddMergedRegion(cellRangeAddress21);
+                    row7.CreateCell(0); row7.CreateCell(1); row7.Cells[0].SetCellValue(DataTable.Rows[i]["STF_MACHINE"].ToString() + "-" + DataTable.Rows[i + 1]["STF_MACHINE"].ToString().Substring(0, 1));
+                 
+
                     IRow row8 = sheet1.CreateRow(7);
                     row8.CreateCell(0); row8.Cells[0].SetCellValue("站位");
                     row8.CreateCell(1); row8.Cells[1].SetCellValue("Feeder类型");