Browse Source

导出BUG调整

callm 5 years ago
parent
commit
5197eb1f90
1 changed files with 357 additions and 207 deletions
  1. 357 207
      UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

+ 357 - 207
UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

@@ -328,6 +328,8 @@ namespace UAS_LabelMachine
             sheet.SetMargin(MarginType.BottomMargin, 0.4);
             sheet.SetMargin(MarginType.LeftMargin, 0.4);
             sheet.SetMargin(MarginType.RightMargin, 0.4);
+            sheet.FitToPage = true;
+            sheet.PrintSetup.FitHeight = 200;
             //芯片号需要作为更新盒号的条件
             HSSFFont ffont = (HSSFFont)book.CreateFont();
             ffont.FontName = "宋体";
@@ -350,7 +352,17 @@ namespace UAS_LabelMachine
             styleborder.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
             styleborder.SetFont(ffont);
             string pi_inoutno = "";
+            HSSFFont ColumnTitle = (HSSFFont)book.CreateFont();
+            ColumnTitle.FontName = "宋体";
+            ColumnTitle.Boldweight = (short)FontBoldWeight.Bold;
 
+            ICellStyle ColumnTitleStyle = book.CreateCellStyle();
+            ColumnTitleStyle.SetFont(ColumnTitle);
+
+            ColumnTitleStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+            ColumnTitleStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+            ColumnTitleStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
+            ColumnTitleStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
 
             List<string> NotShowColumn = new List<string>();
             NotShowColumn.Add("ch_level");
@@ -360,6 +372,7 @@ namespace UAS_LabelMachine
             NotShowColumn.Add("pd_ordercode");
             NotShowColumn.Add("pr_size");
             NotShowColumn.Add("me_desc");
+            NotShowColumn.Add("pr_orispeccode");
             NotShowColumn.Add("pr_orispeccode1");
             NotShowColumn.Add("pi_title");
             //展示的内容列
@@ -468,9 +481,9 @@ namespace UAS_LabelMachine
                             First_OrderCode += DataTable.Rows[i]["pd_ordercode"].ToString() + " ";
                         }
                         //不包含的物料型号
-                        if (DataTable.Columns.Contains("pr_orispeccode1") && !First_Prspec.Contains(DataTable.Rows[i]["pr_orispeccode1"].ToString()))
+                        if (DataTable.Columns.Contains("pr_orispeccode") && !First_Prspec.Contains(DataTable.Rows[i]["pr_orispeccode"].ToString()))
                         {
-                            First_Prspec += DataTable.Rows[i]["pr_orispeccode1"].ToString() + " ";
+                            First_Prspec += DataTable.Rows[i]["pr_orispeccode"].ToString() + " ";
                         }
                         //不包含扩撒批号
                         if (DataTable.Columns.Contains("ch_splitbatch") && !First_Batch.Contains(DataTable.Rows[i]["ch_splitbatch"].ToString()))
@@ -491,7 +504,7 @@ namespace UAS_LabelMachine
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
-                            dr["pr_orispeccode1"] = First_Prspec;
+                            dr["pr_orispeccode"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
                             dr["ch_waterid"] = BaseUtil.GetArrStr(First_WID, " ");
                             dr["num"] = PageSize;
@@ -559,8 +572,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                               + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                               + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -579,29 +596,34 @@ namespace UAS_LabelMachine
                                 //计数列所在的索引
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = styleborder;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
+                                    {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
+                                    }
 
                                     if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
                                     {
                                         NumIndex = j;
                                     }
-                                    //如果chw_itemname1的值为空,则值为100和0,其中一列不显示,不显示
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                        (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
-                                    {
-                                        sheet.SetColumnHidden(j - 4, true);
-                                    }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -634,7 +656,7 @@ namespace UAS_LabelMachine
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
-                            dr["pr_orispeccode1"] = First_Prspec;
+                            dr["pr_orispeccode"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
                             dr["ch_waterid"] = BaseUtil.GetArrStr(First_WID, " ");
                             dr["num"] = (i % PageSize) + 1;
@@ -644,56 +666,51 @@ namespace UAS_LabelMachine
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                                row1.CreateCell(j);
+                                    row1.CreateCell(j);
+                                    if (j == 0)
+                                    {
+                                        row1.Cells[j].SetCellValue(小计);
+                                    }
+                                    else if (j == 1)
+                                    {
+                                        row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : (i % PageSize + 1)) + 片);
+                                    }
+                                    else if (j == 2)
+                                    {
+                                        row1.Cells[2].SetCellValue(sumCount);
+                                    }
+
+                                    row1.Cells[j].CellStyle = styleborder;
+                            }
+                            row1 = sheet.CreateRow(PaintIndex);
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
                                 if (j == 0)
                                 {
-                                    row1.Cells[j].SetCellValue(小计);
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
                                 }
-                                else if (j == 1)
+                                else if (j == 2)
                                 {
-                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : (i % PageSize + 1)) + 片);
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
                                 }
-                                else if (j == 2)
+                                else if (j == 3)
                                 {
-                                    row1.Cells[2].SetCellValue(sumCount);
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
                                 }
-                                row1.Cells[j].CellStyle = styleborder;
+                                else if (j == 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
                             }
-                            row1 = sheet.CreateRow(PaintIndex);
-                            //for (int j = 0; j < columnNum - 3; j++)
-                            //{
-                            //    if (j == 0)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue("备注");
-                            //    }
-                            //    else if (j == 2)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(totalCount);
-                            //    }
-                            //    //原本是j == columnNum - 5因为还有spec和order两列隐藏列,所以需要在往后移动
-                            //    else if (j == columnNum - 6)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(rowNum);
-                            //    }
-                            //    else if (j > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else if (columnNum > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else
-                            //    {
-                            //        row1.CreateCell(j);
-                            //    }
-                            //    row1.Cells[j].CellStyle = style;
-                            //}
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -725,25 +742,26 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                                row1.CreateCell(j);
-                                if (j == 0)
-                                {
-                                    row1.Cells[j].SetCellValue(小计);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else if (j == 1)
-                                {
-                                    row1.Cells[1].SetCellValue(PageNum - 1 + 片);
-                                }
-                                else if (j == 2)
-                                {
-                                    row1.Cells[2].SetCellValue(sumCount);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else
-                                {
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
+                                
+                                    row1.CreateCell(j);
+                                    if (j == 0)
+                                    {
+                                        row1.Cells[j].SetCellValue(小计);
+                                        row1.Cells[j].CellStyle = styleborder;
+                                    }
+                                    else if (j == 1)
+                                    {
+                                        row1.Cells[1].SetCellValue(PageNum - 1 + 片);
+                                    }
+                                    else if (j == 2)
+                                    {
+                                        row1.Cells[2].SetCellValue(sumCount);
+                                        row1.Cells[j].CellStyle = styleborder;
+                                    }
+                                    else
+                                    {
+                                        row1.Cells[j].CellStyle = styleborder;
+                                    }
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
@@ -787,8 +805,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                                                  + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -806,22 +828,28 @@ namespace UAS_LabelMachine
                                 PaintIndex = PaintIndex + 1;
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = styleborder;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                        (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
                                     {
-                                        sheet.SetColumnHidden(j - 4, true);
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
@@ -874,39 +902,34 @@ namespace UAS_LabelMachine
                             }
                             //创建备注内容
                             row1 = sheet.CreateRow(PaintIndex);
-                            //for (int j = 0; j < columnNum - 3; j++)
-                            //{
-                            //    if (j == 0)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue("备注");
-                            //    }
-                            //    else if (j == 2)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(totalCount);
-                            //    }
-                            //    else if (j == columnNum - 6)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(rowNum);
-                            //    }
-                            //    else if (j > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else if (columnNum > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else
-                            //    {
-                            //        row1.CreateCell(j);
-                            //    }
-                            //    row1.Cells[j].CellStyle = style;
-                            //}
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == 3)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -1001,8 +1024,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                                + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                                + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -1020,23 +1047,28 @@ namespace UAS_LabelMachine
                                 PaintIndex = PaintIndex + 1;
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    //设定固定的列名
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = styleborder;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                              (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
                                     {
-                                        sheet.SetColumnHidden(j - 4, true);
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
@@ -1089,39 +1121,34 @@ namespace UAS_LabelMachine
                             }
                             row1 = sheet.CreateRow(PaintIndex);
 
-                            //for (int j = 0; j < columnNum - 3; j++)
-                            //{
-                            //    if (j == 0)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue("备注");
-                            //    }
-                            //    else if (j == 2)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(totalCount);
-                            //    }
-                            //    else if (j == columnNum - 6)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(rowNum);
-                            //    }
-                            //    else if (j > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else if (columnNum > 5 && j == columnNum - 5)
-                            //    {
-                            //        row1.CreateCell(j);
-                            //        row1.Cells[j].SetCellValue(片);
-                            //    }
-                            //    else
-                            //    {
-                            //        row1.CreateCell(j);
-                            //    }
-                            //    row1.Cells[j].CellStyle = style;
-                            //}
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == 3)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -1385,6 +1412,7 @@ namespace UAS_LabelMachine
             NotShowColumn.Add("pd_ordercode");
             NotShowColumn.Add("pr_size");
             NotShowColumn.Add("me_desc");
+            NotShowColumn.Add("pr_orispeccode");
             NotShowColumn.Add("pr_orispeccode1");
             NotShowColumn.Add("pi_title");
             //展示的内容列
@@ -1509,9 +1537,9 @@ namespace UAS_LabelMachine
                             First_OrderCode += DataTable.Rows[i]["pd_ordercode"].ToString() + " ";
                         }
                         //不包含的物料型号
-                        if (DataTable.Columns.Contains("pr_orispeccode1") && !First_Prspec.Contains(DataTable.Rows[i]["pr_orispeccode1"].ToString()))
+                        if (DataTable.Columns.Contains("pr_orispeccode") && !First_Prspec.Contains(DataTable.Rows[i]["pr_orispeccode"].ToString()))
                         {
-                            First_Prspec += DataTable.Rows[i]["pr_orispeccode1"].ToString() + " ";
+                            First_Prspec += DataTable.Rows[i]["pr_orispeccode"].ToString() + " ";
                         }
                         //不包含扩撒批号
                         if (DataTable.Columns.Contains("ch_splitbatch") && !First_Batch.Contains(DataTable.Rows[i]["ch_splitbatch"].ToString()))
@@ -1532,7 +1560,7 @@ namespace UAS_LabelMachine
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
-                            dr["pr_orispeccode1"] = First_Prspec;
+                            dr["pr_orispeccode"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
                             dr["ch_waterid"] = BaseUtil.GetArrStr(First_WID, " ");
                             dr["num"] = PageSize;
@@ -1545,21 +1573,22 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                                row1.CreateCell(j);
-                                if (j == 0)
-                                {
-                                    row1.Cells[j].SetCellValue(小计);
-                                }
-                                else if (j == 1)
-                                {
-                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
-                                    row1.Cells[1].CellStyle = ColumnTitleStyle;
-                                }
-                                else if (j == 2)
-                                {
-                                    row1.Cells[2].SetCellValue(sumCount);
-                                }
-                                row1.Cells[j].CellStyle = styleborder;
+                             
+                                    row1.CreateCell(j);
+                                    if (j == 0)
+                                    {
+                                        row1.Cells[j].SetCellValue(小计);
+                                    }
+                                    else if (j == 1)
+                                    {
+                                        row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                        row1.Cells[1].CellStyle = ColumnTitleStyle;
+                                    }
+                                    else if (j == 2)
+                                    {
+                                        row1.Cells[2].SetCellValue(sumCount);
+                                    }
+                                    row1.Cells[j].CellStyle = styleborder;
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
@@ -1609,8 +1638,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                                  + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") "+ DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -1633,29 +1666,33 @@ namespace UAS_LabelMachine
                                 //计数列所在的索引
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
+                                    {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
-
+                                    }
                                     if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
                                     {
                                         NumIndex = j;
                                     }
-                                    //如果chw_itemname1的值为空,则值为100和0,其中一列不显示,不显示
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
-                                    {
-                                        sheet.SetColumnHidden(j - 4, true);
-                                    }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -1666,8 +1703,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -1688,7 +1733,7 @@ namespace UAS_LabelMachine
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
-                            dr["pr_orispeccode1"] = First_Prspec;
+                            dr["pr_orispeccode"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
                             dr["ch_waterid"] = BaseUtil.GetArrStr(First_WID, " ");
                             dr["num"] = (i % PageSize) + 1;
@@ -1715,6 +1760,34 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = styleborder;
                             }
                             row1 = sheet.CreateRow(PaintIndex);
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == 3)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -1815,8 +1888,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                                    + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                                    + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -1834,22 +1911,28 @@ namespace UAS_LabelMachine
                                 PaintIndex = PaintIndex + 1;
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                        (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
                                     {
-                                        sheet.SetColumnHidden(j - 4, true);
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
@@ -1874,6 +1957,7 @@ namespace UAS_LabelMachine
                                 row1.Cells[j - 4].SetCellValue(i + 1);
                             }
                         }
+
                         if (i == rowNum - 1)
                         {
                             row1 = sheet.CreateRow(PaintIndex);
@@ -1903,6 +1987,34 @@ namespace UAS_LabelMachine
                             }
                             //创建备注内容
                             row1 = sheet.CreateRow(PaintIndex);
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == 3)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -2004,8 +2116,12 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
-                                         + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")  "
-                                         + DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == 3)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                                     }
                                     else if (columnNum > 14 && j == columnNum - 14)
                                     {
@@ -2023,23 +2139,28 @@ namespace UAS_LabelMachine
                                 PaintIndex = PaintIndex + 1;
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    //设定固定的列名
-                                    row1.CreateCell(j - 4);
-                                    row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
                                     }
                                     else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
                                     {
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                                       (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                                    {
+
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
-                                    if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
-                                        (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
                                     {
-                                        sheet.SetColumnHidden(j - 4, true);
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
                                 }
                                 row1 = sheet.CreateRow(PaintIndex);
@@ -2092,6 +2213,34 @@ namespace UAS_LabelMachine
                                 }
                             }
                             row1 = sheet.CreateRow(PaintIndex);
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == 3)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j ==4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -2217,6 +2366,7 @@ namespace UAS_LabelMachine
                     //添加列名
                     for (int j = 4; j < columnNum; j++)
                     {
+
                         row1.CreateCell(j - 4);
                         row1.Cells[j - 4].CellStyle = styleborder;
                         row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);