Browse Source

整数被固定行号导出

callm 5 years ago
parent
commit
4ec7061d84
1 changed files with 108 additions and 12 deletions
  1. 108 12
      UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

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

@@ -478,6 +478,14 @@ namespace UAS_LabelMachine
                             break;
                         }
                     }
+                    if (box[j].Name.ToLower() == "ch_yield" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_yield"))
+                        {
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
                 }
             }
             //获取行数量和列数量
@@ -568,6 +576,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -734,8 +743,8 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    Console.WriteLine(NumIndex);
-                                    row1.Cells[ShowPieceIndex].SetCellValue(rowNum % PageSize + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((rowNum % PageSize==0?PageSize:(rowNum % PageSize))+ 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -775,14 +784,6 @@ namespace UAS_LabelMachine
                         pib_id.Add(DataTable.Rows[i]["pib_id"].ToString());
                         pib_outboxcode1.Add(BoxCode.ToString());
                     }
-                    //for (int i = 0; i < sheet.LastRowNum; i++)
-                    //{
-                    //    //if (i != 0)
-                    //    //{
-                    //    //    sheet.AutoSizeColumn(i);
-                    //    //    sheet.SetColumnWidth(i, sheet.GetColumnWidth(i) + 1000);
-                    //    //}
-                    //}
                     break;
                 case "BatchCode":
                     string LastBatchCode = "";
@@ -807,6 +808,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -967,6 +969,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -1049,6 +1052,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -1210,6 +1214,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -1573,6 +1578,14 @@ namespace UAS_LabelMachine
                             break;
                         }
                     }
+                    if (box[j].Name.ToLower() == "ch_yield" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_yield"))
+                        {
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
                 }
             }
             //获取行数量和列数量
@@ -1866,7 +1879,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(rowNum % PageSize + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((rowNum % PageSize == 0 ? PageSize : (rowNum % PageSize)) + 片);
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == ShowCountIndex)
@@ -2623,6 +2636,7 @@ namespace UAS_LabelMachine
             string 总计 = "";
             string 片 = "";
             string companyname = "";
+            int ShowBoxIndex = 0;
             if (dh.getFieldDataByCondition("ProdInout", "pi_exporttype", "pi_inoutno='" + Inoutno + "'").ToString() == "Chinese")
             {
                 小计 = "小计";
@@ -2754,6 +2768,14 @@ namespace UAS_LabelMachine
                             break;
                         }
                     }
+                    if (box[j].Name.ToLower() == "ch_yield" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_yield"))
+                        {
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
                 }
             }
             //获取行数量和列数量
@@ -2844,11 +2866,17 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 row1.Cells[j].CellStyle = styleborder;
                             }
                             row1 = sheet.CreateRow(PaintIndex);
@@ -2868,6 +2896,11 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 row1.Cells[j].CellStyle = styleborder;
                             }
                             sumCount = 0;
@@ -2967,6 +3000,10 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
+                                    if (DataTable.Columns[j].ColumnName.ToString() == "ch_pbcode")
+                                    {
+                                        ShowBoxIndex = j;
+                                    }
                                     if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
                                     {
                                         NumIndex = j;
@@ -3037,7 +3074,13 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(rowNum % PageSize + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((rowNum % PageSize == 0 ? PageSize : (rowNum % PageSize)) + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -3058,6 +3101,12 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(rowNum % PageSize + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -3130,12 +3179,18 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;
@@ -3154,12 +3209,18 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;
@@ -3263,6 +3324,10 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
+                                    if (DataTable.Columns[j].ColumnName.ToString() == "ch_pbcode")
+                                    {
+                                        ShowBoxIndex = j;
+                                    }
                                     if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
                                     {
                                         NumIndex = j;
@@ -3322,6 +3387,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -3346,6 +3412,7 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
@@ -3424,12 +3491,18 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;
@@ -3448,12 +3521,18 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;
@@ -3556,6 +3635,10 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     }
+                                    if (DataTable.Columns[j].ColumnName.ToString() == "ch_pbcode")
+                                    {
+                                        ShowBoxIndex = j;
+                                    }
                                     if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
                                     {
                                         NumIndex = j;
@@ -3616,12 +3699,19 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;
@@ -3640,12 +3730,18 @@ namespace UAS_LabelMachine
                                 else if (j == ShowPieceIndex)
                                 {
                                     row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
                                 {
                                     row1.Cells[j].SetCellValue(sumCount);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
+                                else if (j == ShowBoxIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(DataTable.Rows[i]["ch_pbcode"].ToString());
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
                                 else
                                 {
                                     row1.Cells[j].CellStyle = styleborder;