Browse Source

修改导出报表

callm 6 months ago
parent
commit
96f31c89f2

+ 34 - 6
UAS_MES_LGDZ/DataOperate/ExcelHandler.cs

@@ -66,15 +66,18 @@ namespace UAS_MES_NEW.DataOperate
             int rowNum = DataTable.Rows.Count;
             int columnNum = DataTable.Columns.Count;
             //设置列的宽度,根据首行的列的内容的长度来设置
+            string SheetName = "";
+            //表格数据游标
+            int DataRowCount = 8;
             for (int i = 0; i < DataTable.Rows.Count; i++)
             {
                 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));
+                    SheetName = 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);
@@ -89,7 +92,7 @@ namespace UAS_MES_NEW.DataOperate
                     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);
@@ -104,7 +107,7 @@ namespace UAS_MES_NEW.DataOperate
                     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);
@@ -141,7 +144,7 @@ namespace UAS_MES_NEW.DataOperate
                     sheet1.AddMergedRegion(cellRangeAddress17);
                     sheet1.AddMergedRegion(cellRangeAddress18);
                     sheet1.AddMergedRegion(cellRangeAddress19);
-                    row6.CreateCell(0); row6.CreateCell(1); row6.Cells[0].SetCellValue("制作:"    );
+                    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审核:");
 
@@ -150,7 +153,6 @@ namespace UAS_MES_NEW.DataOperate
                     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("站位");
@@ -161,7 +163,33 @@ namespace UAS_MES_NEW.DataOperate
                     row8.CreateCell(5); row8.Cells[5].SetCellValue("用量");
                     row8.CreateCell(6); row8.Cells[6].SetCellValue("位号");
                     row8.CreateCell(7); row8.Cells[7].SetCellValue("备注");
+
                     i = i + 1;
+                    DataRowCount = 8;
+                }
+                else
+                {
+                    if (SheetName != "")
+                    {
+                        ISheet sheet = book.GetSheet(SheetName);
+                        IRow row = sheet.CreateRow(DataRowCount);
+                        row.CreateCell(0);
+                        row.CreateCell(1);
+                        row.CreateCell(2);
+                        row.CreateCell(3);
+                        //位置编号
+                        CellRangeAddress cellRangeAddress = new CellRangeAddress(DataRowCount, DataRowCount + 1, 0, 0);
+                        sheet.AddMergedRegion(cellRangeAddress);
+                        //飞达规格
+                        CellRangeAddress cellRangeAddress1 = new CellRangeAddress(DataRowCount, DataRowCount + 1, 1, 1);
+                        sheet.AddMergedRegion(cellRangeAddress1);
+                        row.Cells[0].SetCellValue(DataTable.Rows[i]["STF_MODEL"].ToString());
+                        row.Cells[1].SetCellValue(DataTable.Rows[i]["STF_FEEDER"].ToString());
+                        //物料编号
+                        row.Cells[2].SetCellValue(DataTable.Rows[i]["STF_FEEDERNO"].ToString());
+                        row.Cells[3].SetCellValue(DataTable.Rows[i]["STF_LOCATION"].ToString());
+                        DataRowCount = DataRowCount + 1;
+                    }
                 }
             }
             //将book的内容写入内存流中返回

+ 5 - 5
UAS_MES_LGDZ/FunctionCode/Special/Special_ChangeMakeCode.cs

@@ -87,11 +87,11 @@ namespace UAS_MES_NEW.Special
                 OperateResult.AppendText("工单号" + ma_code1.Text + "不存在\n");
                 return;
             }
-            if (dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code.Text + "'").ToString() != dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code1.Text + "'").ToString())
-            {
-                OperateResult.AppendText("工单号产品编号不对应,不允许切换\n");
-                return;
-            }
+            //if (dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code.Text + "'").ToString() != dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code1.Text + "'").ToString())
+            //{
+            //    OperateResult.AppendText("工单号产品编号不对应,不允许切换\n");
+            //    return;
+            //}
             List<string> sqls = new List<string>();
             sqls.Add("update CRAFTMATERIAL set cm_makecode='" + ma_code1.Text + "' where cm_makecode= '" + ma_code.Text + "'");
             sqls.Add("update steppassed set sp_makecode='" + ma_code1.Text + "' where sp_makecode= '" + ma_code.Text + "'");