Selaa lähdekoodia

特殊报表导出

callm 1 vuosi sitten
vanhempi
commit
3a71be76a9

+ 12 - 2
UAS_MES_LGDZ/DataOperate/ExcelHandler.cs

@@ -90,9 +90,9 @@ namespace UAS_MES_NEW.DataOperate
                     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(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);
@@ -166,6 +166,7 @@ namespace UAS_MES_NEW.DataOperate
 
                     i = i + 1;
                     DataRowCount = 8;
+                    sheet1.SetColumnWidth(4,sheet1.GetColumnWidth(4)+3500);
                 }
                 else
                 {
@@ -177,6 +178,9 @@ namespace UAS_MES_NEW.DataOperate
                         row.CreateCell(1);
                         row.CreateCell(2);
                         row.CreateCell(3);
+                        row.CreateCell(4);
+                        row.CreateCell(5);
+                        row.CreateCell(6);
                         //位置编号
                         CellRangeAddress cellRangeAddress = new CellRangeAddress(DataRowCount, DataRowCount + 1, 0, 0);
                         sheet.AddMergedRegion(cellRangeAddress);
@@ -188,8 +192,14 @@ namespace UAS_MES_NEW.DataOperate
                         //物料编号
                         row.Cells[2].SetCellValue(DataTable.Rows[i]["STF_FEEDERNO"].ToString());
                         row.Cells[3].SetCellValue(DataTable.Rows[i]["STF_LOCATION"].ToString());
+                        row.Cells[4].SetCellValue(DataTable.Rows[i]["pr_orispeccode"].ToString());
+                        row.Cells[4].CellStyle.WrapText = true;
+                        row.Cells[5].SetCellValue(DataTable.Rows[i]["bd_baseqty"].ToString());
+                        row.Cells[6].SetCellValue(DataTable.Rows[i]["bd_soncode"].ToString());
+                        row.Cells[4].CellStyle.ShrinkToFit = true;
                         DataRowCount = DataRowCount + 1;
                     }
+                 
                 }
             }
             //将book的内容写入内存流中返回

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.cs

@@ -202,7 +202,7 @@ namespace UAS_MES_NEW.Query
                     new string[] { "STF_MODEL", "STF_FEEDER", "STF_FEEDERNO", "STF_LOCATION", "STF_MACHINE" }, STF_MODEL.ToArray(), STF_FEEDER.ToArray(), STF_FEEDERNO.ToArray(), STF_LOCATION.ToArray(), STF_MACHINE.ToArray());
                 dh.ExecuteSql("delete from SMTTRACEFILE where ( STF_MODEL is null and  STF_FEEDER is null and STF_FEEDERNO is null and STF_MACHINE is null ) or stf_model in ('料槽','数量','印刷板') or STF_MACHINE in('贴片生产线:','设置:') ", "delete");
                 dataGridView1.DataSource = dt;
-                DataTable dt1 = (DataTable)dh.ExecuteSql("select STF_ID, STF_MODEL,STF_MACHINE, STF_FEEDER, STF_FEEDERNO, STF_LOCATION,pr_orispeccode,bo_mothercode,bd_baseqty,bd_soncode,bd_location, STF_CODE, STF_INDATE, STF_INMAN from SMTTRACEFILE left join (\r\nselect bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail \r\nLEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code left join ProdReplace on pre_bdid =bd_id where bo_mothercode='" + pr_code.Text + "' ) on bo_mothercode=stf_prodcode and bd_soncode=STF_LOCATION \r\nleft join product on pr_code=STF_LOCATION where stf_prodcode='"+pr_code.Text+"' order by stf_id", "select");
+                DataTable dt1 = (DataTable)dh.ExecuteSql("select STF_ID, STF_MODEL,STF_MACHINE, STF_FEEDER, STF_FEEDERNO, STF_LOCATION,replace(pr_orispeccode,' ','\n')pr_orispeccode,bo_mothercode,bd_baseqty,bd_soncode,bd_location, STF_CODE, STF_INDATE, STF_INMAN from SMTTRACEFILE left join (\r\nselect bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail \r\nLEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code left join ProdReplace on pre_bdid =bd_id where bo_mothercode='" + pr_code.Text + "' ) on bo_mothercode=stf_prodcode and bd_soncode=STF_LOCATION \r\nleft join product on pr_code=STF_LOCATION where stf_prodcode='"+pr_code.Text+"' order by stf_id", "select");
                 excel.ExportExcel_LIANGAN(dt1, "C:\\Users\\callm\\Desktop\\客户资料\\"+System.DateTime.Now.ToString("yyyyMMddhhmmss")+".xls");
             }
         }