Просмотр исходного кода

修改可支持配置导出Excel字段

章政 6 лет назад
Родитель
Сommit
cd90e5ba96

+ 1 - 1
UAS-出货标签管理(贸易版)/CustomControl/Pagination.cs

@@ -254,7 +254,7 @@ namespace UAS_LabelMachine.CustomControl
                 string FolderPath = folderBrowserDialog1.SelectedPath;
                 ExcelHandler eh = new ExcelHandler();
                 //导出Excel的时候返回一个文件名,用户选择是否打开
-                string filePath = eh.ExportExcel(BaseUtil.GetExportDataTable(Dgv), BaseUtil.GetExportDataTable(Dgv), FolderPath, "客户标签","",100,false);
+                string filePath = eh.ExportExcel(BaseUtil.GetExportDataTable(Dgv), BaseUtil.GetExportDataTable(Dgv), FolderPath, "客户标签","",100,null);
                 //用户选择导出之后是否立即打开
                 MessageBoxButtons messButton = MessageBoxButtons.YesNo;
                 string openFile = MessageBox.Show(this.ParentForm, "是否打开文件", "提示", messButton).ToString();

+ 103 - 48
UAS-出货标签管理(贸易版)/ExportExcel.Designer.cs

@@ -49,15 +49,18 @@
             this.FixRow = new System.Windows.Forms.RadioButton();
             this.label7 = new System.Windows.Forms.Label();
             this.FirstPage_WID = new System.Windows.Forms.CheckBox();
-            this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
+            this.FirstPage_YIELD = new System.Windows.Forms.CheckBox();
+            this.FirstPage_REMARK = new System.Windows.Forms.CheckBox();
+            this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
             this.SuspendLayout();
             // 
             // Export
             // 
-            this.Export.Location = new System.Drawing.Point(479, 576);
+            this.Export.Location = new System.Drawing.Point(240, 288);
+            this.Export.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.Export.Name = "Export";
-            this.Export.Size = new System.Drawing.Size(189, 49);
+            this.Export.Size = new System.Drawing.Size(94, 24);
             this.Export.TabIndex = 0;
             this.Export.Text = "导出";
             this.Export.UseVisualStyleBackColor = true;
@@ -69,9 +72,10 @@
             this.CH_BLUEFILM.Checked = true;
             this.CH_BLUEFILM.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_BLUEFILM.Font = new System.Drawing.Font("宋体", 10F);
-            this.CH_BLUEFILM.Location = new System.Drawing.Point(259, 115);
+            this.CH_BLUEFILM.Location = new System.Drawing.Point(130, 58);
+            this.CH_BLUEFILM.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.CH_BLUEFILM.Name = "CH_BLUEFILM";
-            this.CH_BLUEFILM.Size = new System.Drawing.Size(125, 31);
+            this.CH_BLUEFILM.Size = new System.Drawing.Size(68, 18);
             this.CH_BLUEFILM.TabIndex = 1;
             this.CH_BLUEFILM.Text = "蓝膜号";
             this.CH_BLUEFILM.UseVisualStyleBackColor = true;
@@ -82,9 +86,10 @@
             this.CH_SPLITBATCH.Checked = true;
             this.CH_SPLITBATCH.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_SPLITBATCH.Font = new System.Drawing.Font("宋体", 10F);
-            this.CH_SPLITBATCH.Location = new System.Drawing.Point(701, 115);
+            this.CH_SPLITBATCH.Location = new System.Drawing.Point(350, 58);
+            this.CH_SPLITBATCH.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.CH_SPLITBATCH.Name = "CH_SPLITBATCH";
-            this.CH_SPLITBATCH.Size = new System.Drawing.Size(152, 31);
+            this.CH_SPLITBATCH.Size = new System.Drawing.Size(82, 18);
             this.CH_SPLITBATCH.TabIndex = 3;
             this.CH_SPLITBATCH.Text = "扩散批号";
             this.CH_SPLITBATCH.UseVisualStyleBackColor = true;
@@ -95,9 +100,10 @@
             this.CH_PBCODE.Checked = true;
             this.CH_PBCODE.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_PBCODE.Font = new System.Drawing.Font("宋体", 10F);
-            this.CH_PBCODE.Location = new System.Drawing.Point(259, 189);
+            this.CH_PBCODE.Location = new System.Drawing.Point(130, 94);
+            this.CH_PBCODE.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.CH_PBCODE.Name = "CH_PBCODE";
-            this.CH_PBCODE.Size = new System.Drawing.Size(98, 31);
+            this.CH_PBCODE.Size = new System.Drawing.Size(54, 18);
             this.CH_PBCODE.TabIndex = 8;
             this.CH_PBCODE.Text = "盒号";
             this.CH_PBCODE.UseVisualStyleBackColor = true;
@@ -108,9 +114,10 @@
             this.CH_REMARK.Checked = true;
             this.CH_REMARK.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_REMARK.Font = new System.Drawing.Font("宋体", 10F);
-            this.CH_REMARK.Location = new System.Drawing.Point(487, 189);
+            this.CH_REMARK.Location = new System.Drawing.Point(244, 94);
+            this.CH_REMARK.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.CH_REMARK.Name = "CH_REMARK";
-            this.CH_REMARK.Size = new System.Drawing.Size(152, 31);
+            this.CH_REMARK.Size = new System.Drawing.Size(82, 18);
             this.CH_REMARK.TabIndex = 9;
             this.CH_REMARK.Text = "芯片备注";
             this.CH_REMARK.UseVisualStyleBackColor = true;
@@ -121,9 +128,10 @@
             this.ch_code.Checked = true;
             this.ch_code.CheckState = System.Windows.Forms.CheckState.Checked;
             this.ch_code.Font = new System.Drawing.Font("宋体", 10F);
-            this.ch_code.Location = new System.Drawing.Point(487, 115);
+            this.ch_code.Location = new System.Drawing.Point(244, 58);
+            this.ch_code.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.ch_code.Name = "ch_code";
-            this.ch_code.Size = new System.Drawing.Size(125, 31);
+            this.ch_code.Size = new System.Drawing.Size(68, 18);
             this.ch_code.TabIndex = 10;
             this.ch_code.Text = "芯片号";
             this.ch_code.UseVisualStyleBackColor = true;
@@ -134,9 +142,10 @@
             this.CH_WATERID.Checked = true;
             this.CH_WATERID.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_WATERID.Font = new System.Drawing.Font("宋体", 10F);
-            this.CH_WATERID.Location = new System.Drawing.Point(905, 115);
+            this.CH_WATERID.Location = new System.Drawing.Point(452, 58);
+            this.CH_WATERID.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.CH_WATERID.Name = "CH_WATERID";
-            this.CH_WATERID.Size = new System.Drawing.Size(156, 31);
+            this.CH_WATERID.Size = new System.Drawing.Size(82, 18);
             this.CH_WATERID.TabIndex = 11;
             this.CH_WATERID.Text = "Wafer_ID";
             this.CH_WATERID.UseVisualStyleBackColor = true;
@@ -145,9 +154,10 @@
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("宋体", 10F);
-            this.label1.Location = new System.Drawing.Point(22, 52);
+            this.label1.Location = new System.Drawing.Point(11, 26);
+            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(120, 27);
+            this.label1.Size = new System.Drawing.Size(63, 14);
             this.label1.TabIndex = 12;
             this.label1.Text = "打印选项";
             // 
@@ -155,9 +165,10 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("宋体", 10F);
-            this.label2.Location = new System.Drawing.Point(22, 119);
+            this.label2.Location = new System.Drawing.Point(11, 60);
+            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(215, 27);
+            this.label2.Size = new System.Drawing.Size(112, 14);
             this.label2.TabIndex = 13;
             this.label2.Text = "请选择打印内容:";
             // 
@@ -165,9 +176,10 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("宋体", 10F);
-            this.label3.Location = new System.Drawing.Point(22, 261);
+            this.label3.Location = new System.Drawing.Point(11, 130);
+            this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(216, 27);
+            this.label3.Size = new System.Drawing.Size(112, 14);
             this.label3.TabIndex = 14;
             this.label3.Text = "参数选择(机测):";
             // 
@@ -175,9 +187,10 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("宋体", 10F);
-            this.label4.Location = new System.Drawing.Point(22, 351);
+            this.label4.Location = new System.Drawing.Point(11, 176);
+            this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(216, 27);
+            this.label4.Size = new System.Drawing.Size(112, 14);
             this.label4.TabIndex = 15;
             this.label4.Text = "参数选择(手测):";
             // 
@@ -187,9 +200,10 @@
             this.BVCEO.Checked = true;
             this.BVCEO.CheckState = System.Windows.Forms.CheckState.Checked;
             this.BVCEO.Font = new System.Drawing.Font("宋体", 10F);
-            this.BVCEO.Location = new System.Drawing.Point(487, 347);
+            this.BVCEO.Location = new System.Drawing.Point(244, 174);
+            this.BVCEO.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.BVCEO.Name = "BVCEO";
-            this.BVCEO.Size = new System.Drawing.Size(114, 31);
+            this.BVCEO.Size = new System.Drawing.Size(61, 18);
             this.BVCEO.TabIndex = 17;
             this.BVCEO.Text = "BVCEO";
             this.BVCEO.UseVisualStyleBackColor = true;
@@ -200,9 +214,10 @@
             this.TS.Checked = true;
             this.TS.CheckState = System.Windows.Forms.CheckState.Checked;
             this.TS.Font = new System.Drawing.Font("宋体", 10F);
-            this.TS.Location = new System.Drawing.Point(259, 347);
+            this.TS.Location = new System.Drawing.Point(130, 174);
+            this.TS.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.TS.Name = "TS";
-            this.TS.Size = new System.Drawing.Size(72, 31);
+            this.TS.Size = new System.Drawing.Size(40, 18);
             this.TS.TabIndex = 18;
             this.TS.Text = "TS";
             this.TS.UseVisualStyleBackColor = true;
@@ -213,9 +228,10 @@
             this.percent.Checked = true;
             this.percent.CheckState = System.Windows.Forms.CheckState.Checked;
             this.percent.Font = new System.Drawing.Font("宋体", 10F);
-            this.percent.Location = new System.Drawing.Point(259, 257);
+            this.percent.Location = new System.Drawing.Point(130, 128);
+            this.percent.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.percent.Name = "percent";
-            this.percent.Size = new System.Drawing.Size(86, 31);
+            this.percent.Size = new System.Drawing.Size(47, 18);
             this.percent.TabIndex = 19;
             this.percent.Text = "HFS";
             this.percent.UseVisualStyleBackColor = true;
@@ -224,9 +240,10 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("宋体", 10F);
-            this.label5.Location = new System.Drawing.Point(22, 508);
+            this.label5.Location = new System.Drawing.Point(11, 254);
+            this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(188, 27);
+            this.label5.Size = new System.Drawing.Size(98, 14);
             this.label5.TabIndex = 20;
             this.label5.Text = "首页打印方式:";
             // 
@@ -234,9 +251,10 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("宋体", 10F);
-            this.label6.Location = new System.Drawing.Point(22, 433);
+            this.label6.Location = new System.Drawing.Point(11, 216);
+            this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(188, 27);
+            this.label6.Size = new System.Drawing.Size(98, 14);
             this.label6.TabIndex = 21;
             this.label6.Text = "打印分页方式:";
             // 
@@ -244,9 +262,10 @@
             // 
             this.BatchCode.AutoSize = true;
             this.BatchCode.Font = new System.Drawing.Font("宋体", 10F);
-            this.BatchCode.Location = new System.Drawing.Point(259, 431);
+            this.BatchCode.Location = new System.Drawing.Point(130, 216);
+            this.BatchCode.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.BatchCode.Name = "BatchCode";
-            this.BatchCode.Size = new System.Drawing.Size(124, 31);
+            this.BatchCode.Size = new System.Drawing.Size(67, 18);
             this.BatchCode.TabIndex = 22;
             this.BatchCode.Text = "扩散批";
             this.BatchCode.UseVisualStyleBackColor = true;
@@ -255,9 +274,10 @@
             // 
             this.BoxCode.AutoSize = true;
             this.BoxCode.Font = new System.Drawing.Font("宋体", 10F);
-            this.BoxCode.Location = new System.Drawing.Point(445, 431);
+            this.BoxCode.Location = new System.Drawing.Point(222, 216);
+            this.BoxCode.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.BoxCode.Name = "BoxCode";
-            this.BoxCode.Size = new System.Drawing.Size(97, 31);
+            this.BoxCode.Size = new System.Drawing.Size(53, 18);
             this.BoxCode.TabIndex = 23;
             this.BoxCode.Text = "盒号";
             this.BoxCode.UseVisualStyleBackColor = true;
@@ -267,9 +287,10 @@
             this.FixRow.AutoSize = true;
             this.FixRow.Checked = true;
             this.FixRow.Font = new System.Drawing.Font("宋体", 10F);
-            this.FixRow.Location = new System.Drawing.Point(611, 431);
+            this.FixRow.Location = new System.Drawing.Point(306, 216);
+            this.FixRow.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.FixRow.Name = "FixRow";
-            this.FixRow.Size = new System.Drawing.Size(151, 31);
+            this.FixRow.Size = new System.Drawing.Size(81, 18);
             this.FixRow.TabIndex = 24;
             this.FixRow.TabStop = true;
             this.FixRow.Text = "固定行号";
@@ -279,37 +300,68 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("宋体", 10F);
-            this.label7.Location = new System.Drawing.Point(810, 431);
+            this.label7.Location = new System.Drawing.Point(405, 216);
+            this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label7.Name = "label7";
-            this.label7.Size = new System.Drawing.Size(134, 27);
+            this.label7.Size = new System.Drawing.Size(70, 14);
             this.label7.TabIndex = 25;
             this.label7.Text = "分页行数:";
             // 
             // FirstPage_WID
             // 
             this.FirstPage_WID.AutoSize = true;
+            this.FirstPage_WID.Checked = true;
+            this.FirstPage_WID.CheckState = System.Windows.Forms.CheckState.Checked;
             this.FirstPage_WID.Font = new System.Drawing.Font("宋体", 10F);
-            this.FirstPage_WID.Location = new System.Drawing.Point(259, 508);
+            this.FirstPage_WID.Location = new System.Drawing.Point(130, 254);
+            this.FirstPage_WID.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.FirstPage_WID.Name = "FirstPage_WID";
-            this.FirstPage_WID.Size = new System.Drawing.Size(210, 31);
+            this.FirstPage_WID.Size = new System.Drawing.Size(110, 18);
             this.FirstPage_WID.TabIndex = 29;
             this.FirstPage_WID.Text = "打印Wafer id";
             this.FirstPage_WID.UseVisualStyleBackColor = true;
             // 
+            // FirstPage_YIELD
+            // 
+            this.FirstPage_YIELD.AutoSize = true;
+            this.FirstPage_YIELD.Font = new System.Drawing.Font("宋体", 10F);
+            this.FirstPage_YIELD.Location = new System.Drawing.Point(244, 254);
+            this.FirstPage_YIELD.Margin = new System.Windows.Forms.Padding(2);
+            this.FirstPage_YIELD.Name = "FirstPage_YIELD";
+            this.FirstPage_YIELD.Size = new System.Drawing.Size(54, 18);
+            this.FirstPage_YIELD.TabIndex = 31;
+            this.FirstPage_YIELD.Text = "良率";
+            this.FirstPage_YIELD.UseVisualStyleBackColor = true;
+            // 
+            // FirstPage_REMARK
+            // 
+            this.FirstPage_REMARK.AutoSize = true;
+            this.FirstPage_REMARK.Font = new System.Drawing.Font("宋体", 10F);
+            this.FirstPage_REMARK.Location = new System.Drawing.Point(304, 254);
+            this.FirstPage_REMARK.Margin = new System.Windows.Forms.Padding(2);
+            this.FirstPage_REMARK.Name = "FirstPage_REMARK";
+            this.FirstPage_REMARK.Size = new System.Drawing.Size(54, 18);
+            this.FirstPage_REMARK.TabIndex = 32;
+            this.FirstPage_REMARK.Text = "备注";
+            this.FirstPage_REMARK.UseVisualStyleBackColor = true;
+            // 
             // RowNum
             // 
-            this.RowNum.Location = new System.Drawing.Point(961, 431);
+            this.RowNum.Location = new System.Drawing.Point(480, 216);
+            this.RowNum.Margin = new System.Windows.Forms.Padding(2);
             this.RowNum.Name = "RowNum";
             this.RowNum.Negative = false;
-            this.RowNum.Size = new System.Drawing.Size(100, 35);
+            this.RowNum.Size = new System.Drawing.Size(52, 21);
             this.RowNum.TabIndex = 30;
-            this.RowNum.Text = "10";
+            this.RowNum.Text = "2";
             // 
             // ExportExcel
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1144, 675);
+            this.ClientSize = new System.Drawing.Size(572, 338);
+            this.Controls.Add(this.FirstPage_REMARK);
+            this.Controls.Add(this.FirstPage_YIELD);
             this.Controls.Add(this.RowNum);
             this.Controls.Add(this.FirstPage_WID);
             this.Controls.Add(this.label7);
@@ -332,6 +384,7 @@
             this.Controls.Add(this.CH_SPLITBATCH);
             this.Controls.Add(this.CH_BLUEFILM);
             this.Controls.Add(this.Export);
+            this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.Name = "ExportExcel";
             this.Text = "导出数据";
             this.Load += new System.EventHandler(this.ExportExcel_Load);
@@ -365,5 +418,7 @@
         private System.Windows.Forms.CheckBox FirstPage_WID;
         private CustomControl.NumOnlyTextBox RowNum;
         private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
+        private System.Windows.Forms.CheckBox FirstPage_YIELD;
+        private System.Windows.Forms.CheckBox FirstPage_REMARK;
     }
 }

+ 53 - 46
UAS-出货标签管理(贸易版)/ExportExcel.cs

@@ -30,7 +30,7 @@ namespace UAS_LabelMachine
             if (result == DialogResult.OK)
             {
                 StringBuilder sql = new StringBuilder();
-                string SqlField = "";
+                List<CheckBox> conditionbox = new List<CheckBox>();
                 if (!CH_PBCODE.Checked && BoxCode.Checked)
                 {
                     MessageBox.Show("勾选盒号分页,打印内容请勾选盒号");
@@ -41,43 +41,18 @@ namespace UAS_LabelMachine
                     MessageBox.Show("勾选扩撒批分页,打印内容请勾选扩撒批号");
                     return;
                 }
-                if (CH_BLUEFILM.Checked)
-                {
-                    SqlField += "CH_BLUEFILM " + CH_BLUEFILM.Text + ",";
-                }
-                if (CH_PBCODE.Checked)
-                {
-                    SqlField += "CH_PBCODE " + CH_PBCODE.Text + ",";
-                }
-                if (CH_REMARK.Checked)
-                {
-                    SqlField += "CH_REMARK " + CH_REMARK.Text + ",";
-                }
-                if (CH_SPLITBATCH.Checked)
-                {
-                    SqlField += "CH_SPLITBATCH " + CH_SPLITBATCH.Text + ",";
-                }
-                if (CH_WATERID.Checked)
-                {
-                    SqlField += "CH_WATERID " + CH_WATERID.Text + ",";
-                }
-                if (ch_code.Checked)
-                {
-                    SqlField += "ch_code " + ch_code.Text + ",";
-                }
-                if (percent.Checked)
-                {
-                    SqlField += "chw_percent1,chw_percent2,chw_itemname1,chw_itemname2,";
-                }
-                if (TS.Checked)
-                {
-                    SqlField += "TS1,TS2,TS3,";
-                }
-                if (BVCEO.Checked)
-                {
-                    SqlField += "BVCEO1,BVCEO2,BVCEO3,";
-                }
-                SqlField += "pd_ordercode,pr_spec,";
+                conditionbox.Add(CH_BLUEFILM);
+                conditionbox.Add(CH_PBCODE);
+                conditionbox.Add(CH_REMARK);
+                conditionbox.Add(CH_SPLITBATCH);
+                conditionbox.Add(CH_WATERID);
+                conditionbox.Add(ch_code);
+                conditionbox.Add(percent);
+                conditionbox.Add(TS);
+                conditionbox.Add(BVCEO);
+                conditionbox.Add(FirstPage_WID);
+                conditionbox.Add(FirstPage_YIELD);
+                conditionbox.Add(FirstPage_REMARK);
                 string SplitType = "";
                 if (FixRow.Checked)
                 {
@@ -91,20 +66,52 @@ namespace UAS_LabelMachine
                 {
                     SplitType = BoxCode.Name;
                 }
-
+                DataTable SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 order by es_detno", "select");
+                string es_field1 = "";
+                for (int i = 0; i < SQL1_.Rows.Count; i++)
+                {
+                    es_field1 += SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString() + ",";
+                }
                 //分页信息的DataTable
                 sql.Clear();
-                sql.Append("select '客户:'||pi_title,'出货单号:'||pi_inoutno,'型号'||pr_spec||' 销售类型:市场部','销售日期:'||pi_date,rownum 序号,io_qty,");
-                sql.Append("" + SqlField.Substring(0, SqlField.Length - 1) + " from  prodinout left join prodiodetail on pi_id=pd_piid left join chip_in_out ");
-                sql.Append("on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode ");
+                sql.Append("select " + es_field1.Substring(0, es_field1.Length - 1)+ " from  prodinout left join prodiodetail on pi_id=pd_piid left join ");
+                sql.Append("chip_in_out on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode ");
                 sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode where pi_inoutno='" + inoutno + "' order by io_detno");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+
+                for (int i = 0; i < dt.Columns.Count; i++)
+                {
+                    if (dt.Columns[i].ColumnName == (SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString()).ToUpper())
+                    {
+                        dt.Columns[i].ColumnName = SQL1_.Rows[i]["es_filed1"].ToString();
+                        dt.Columns[i].Caption = SQL1_.Rows[i]["es_caption"].ToString();
+                    }
+                }
+
+                //获取首页需要展示的字段
+                DataTable SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 order by es_detno", "select");
+                string es_field = "";
+                for (int i = 0; i < SQL_.Rows.Count; i++)
+                {
+                    es_field += SQL_.Rows[i]["es_prefix"].ToString() + "||" + SQL_.Rows[i]["es_filed"].ToString() + "||" + SQL_.Rows[i]["es_suffix"].ToString() + ",";
+                }
                 //首页信息的DataTable
                 sql.Clear();
-                sql.Append("select '客户:'||pi_title 客户,'出货单号:'||pi_inoutno 出货单号,'型号'||pr_spec||' 销售类型:市场部' 型号,");
-                sql.Append("'销售日期:'||pi_date 销售日期,pd_ordercode,pr_spec,ch_splitbatch,ch_waterid,num,io_qty from FIRSTPAGE_BATCH_VIEW where pi_inoutno='" + inoutno + "'");
+                sql.Append("select " + es_field.Substring(0, es_field.Length - 1) + "  from FIRSTPAGE_BATCH_VIEW where pi_inoutno='" + inoutno + "'");
                 DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                eh.ExportExcel(dt1, dt, ExportFileDialog.SelectedPath, inoutno, SplitType, int.Parse(RowNum.Text), FirstPage_WID.Checked);
+                for (int i = 0; i < dt1.Columns.Count; i++)
+                {
+                    if (dt1.Columns[i].ColumnName == (SQL_.Rows[i]["es_prefix"].ToString() + "||" + SQL_.Rows[i]["es_filed"].ToString() + "||" + SQL_.Rows[i]["es_suffix"].ToString()).ToUpper())
+                    {
+                        dt1.Columns[i].ColumnName = SQL_.Rows[i]["es_filed1"].ToString();
+                        dt1.Columns[i].Caption = SQL_.Rows[i]["es_caption"].ToString();
+                    }
+                }
+                eh.ExportExcel(dt1, dt, ExportFileDialog.SelectedPath, inoutno, SplitType, int.Parse(RowNum.Text), conditionbox);
+                string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                if (close.ToString() == "Yes")
+                    System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + inoutno + ".xls");
+                Close();
             }
         }
 
@@ -113,4 +120,4 @@ namespace UAS_LabelMachine
 
         }
     }
-}
+}

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

@@ -7,6 +7,8 @@ using NPOI.XSSF.UserModel;
 using System;
 using UAS_LabelMachine.Entity;
 using UAS_LabelMachine.PublicMethod;
+using System.Collections.Generic;
+using System.Windows.Forms;
 
 namespace UAS_LabelMachine
 {
@@ -37,11 +39,11 @@ namespace UAS_LabelMachine
         /// <summary>
         /// 导出Excel,返回文件在客户端的路径
         /// </summary>
-        public string ExportExcel(DataTable firstsdt, DataTable dt, string FolderPath, string FileName, string Type, int PageSize, bool PrintWID)
+        public string ExportExcel(DataTable firstsdt, DataTable dt, string FolderPath, string FileName, string Type, int PageSize, List<CheckBox> conditionbox)
         {
             //创建一个内存流,用来接收转换成Excel的内容
             MemoryStream ms;
-            ms = DataTableToExcel1(firstsdt, dt, Type, PageSize, PrintWID);
+            ms = DataTableToExcel1(firstsdt, dt, Type, PageSize, conditionbox);
             //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
             string filePath = @FolderPath + "\\" + FileName + ".xls";
             FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
@@ -229,10 +231,10 @@ namespace UAS_LabelMachine
             style.FillPattern = FillPattern.BigSpots;
             style.FillBackgroundColor = HSSFColor.LightGreen.Index;
             //设置边框
-            style.BorderBottom = BorderStyle.Thick;
-            style.BorderLeft = BorderStyle.Thick;
-            style.BorderRight = BorderStyle.Thick;
-            style.BorderTop = BorderStyle.Thick;
+            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
+            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
+            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
+            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
             row.HeightInPoints = 20;
             //固定第一行
             //row.RowStyle.IsLocked=true;
@@ -242,8 +244,8 @@ namespace UAS_LabelMachine
                 row.CreateCell(j);
                 row.Cells[j].CellStyle = style;
                 row.Cells[j].CellStyle.VerticalAlignment = VerticalAlignment.Center;
-                row.Cells[j].CellStyle.Alignment = HorizontalAlignment.Center;
-                row.Cells[j].SetCellValue(DataTable.Columns[j].ColumnName);
+                row.Cells[j].CellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
+                row.Cells[j].SetCellValue(DataTable.Columns[j].Caption);
             }
             //将DataTable的值循环赋值给book,Aligment设置居中
             //之前已经画了带颜色的第一行,所以从i=1开始画
@@ -269,65 +271,118 @@ namespace UAS_LabelMachine
         /// </summary>
         /// <param name="DataTable"></param>
         /// <returns></returns>
-        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type, int PageSize, bool PrintWID)
+        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type, int PageSize, List<CheckBox> conditionbox)
         {
+            //转换为序列
+            CheckBox[] box = conditionbox.ToArray();
             //创建内存流
             MemoryStream ms = new MemoryStream();
             //创建一个Book,相当于一个Excel文件
             HSSFWorkbook book = new HSSFWorkbook();
             //Excel中的Sheet
             ISheet sheet = book.CreateSheet("分页");
-            //获取行数量和列数量
-            int rowNum = DataTable.Rows.Count;
-            int columnNum = DataTable.Columns.Count;
+         
 
             ICellStyle style = book.CreateCellStyle();
             style.VerticalAlignment = VerticalAlignment.Center;
-            style.Alignment = HorizontalAlignment.Left;
+            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
 
             ICellStyle styleborder = book.CreateCellStyle();
-            styleborder.BorderBottom = BorderStyle.Thick;
-            styleborder.BorderTop = BorderStyle.Thick;
-            styleborder.BorderLeft = BorderStyle.Thick;
-            styleborder.BorderRight = BorderStyle.Thick;
+            styleborder.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
+            styleborder.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
+            styleborder.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
+            styleborder.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
             styleborder.VerticalAlignment = VerticalAlignment.Center;
-            styleborder.Alignment = HorizontalAlignment.Left;
+            styleborder.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
             //设置列的宽度,根据首行的列的内容的长度来设置
-            for (int i = 0; i < columnNum; i++)
+            for (int i = DataTable.Columns.Count - 1; i > 0; i--)
             {
-                if (DataTable.Columns[i].ColumnName.Contains("客户"))
-                {
-                    DataTable.Columns[i].ColumnName = "客户";
-                }
-                if (DataTable.Columns[i].ColumnName.Contains("出货单号"))
-                {
-                    DataTable.Columns[i].ColumnName = "出货单号";
-                }
-                if (DataTable.Columns[i].ColumnName.Contains("型号"))
-                {
-                    DataTable.Columns[i].ColumnName = "型号";
-                }
-                if (DataTable.Columns[i].ColumnName.Contains("销售日期"))
-                {
-                    DataTable.Columns[i].ColumnName = "销售日期";
-                }
-                if (DataTable.Columns[i].ColumnName.ToLower().Contains("rownum"))
+                for (int j = 0; j < box.Length; j++)
                 {
-                    DataTable.Columns[i].ColumnName = "序号";
-                }
-                if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_code"))
-                {
-                    DataTable.Columns[i].ColumnName = "芯片号";
-                }
-                if (DataTable.Columns[i].ColumnName.ToLower().Contains("pib_lotno"))
-                {
-                    DataTable.Columns[i].ColumnName = "LotNo";
-                }
-                if (DataTable.Columns[i].ColumnName.ToLower().Contains("io_qty"))
-                {
-                    DataTable.Columns[i].ColumnName = "数量";
+                    if (box[j].Name.ToLower() == "ch_bluefilm" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_bluefilm"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ch_code" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_code"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ch_splitbatch" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ch_waterid" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ch_pbcode" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_pbcode"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ch_remark" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_remark"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "percent" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("chw_percent1") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_percent2") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_itemname1") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_itemname2"))
+                        {
+                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "ts" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower() == ("ts1") || DataTable.Columns[i].ColumnName.ToLower() == ("ts2") || DataTable.Columns[i].ColumnName.ToLower() == ("ts3"))
+                        {
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
+                    if (box[j].Name.ToLower() == "bvceo" && !box[j].Checked)
+                    {
+                        if (DataTable.Columns[i].ColumnName.ToLower()=="bvceo1" || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo2") || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo3"))
+                        {
+                            DataTable.Columns.RemoveAt(i);
+                            break;
+                        }
+                    }
                 }
             }
+            //获取行数量和列数量
+            int rowNum = DataTable.Rows.Count;
+            int columnNum = DataTable.Columns.Count;
             //首先画好第一行带颜色的,单独写出来,避免写在循环里面
             IRow row = sheet.CreateRow(0);
             //冻结第一行
@@ -376,9 +431,9 @@ namespace UAS_LabelMachine
                             First_Prspec += DataTable.Rows[i]["pr_spec"].ToString() + " ";
                         }
                         //不包含扩撒批号
-                        if (DataTable.Columns.Contains("扩散批号") && !First_Batch.Contains(DataTable.Rows[i]["扩散批号"].ToString()))
+                        if (DataTable.Columns.Contains("ch_splitbatch") && !First_Batch.Contains(DataTable.Rows[i]["ch_splitbatch"].ToString()))
                         {
-                            First_Batch += DataTable.Rows[i]["扩散批号"].ToString() + " ";
+                            First_Batch += DataTable.Rows[i]["ch_splitbatch"].ToString() + " ";
                         }
                         //不包含Wafer_id
                         if (DataTable.Columns.Contains("Wafer_ID") && !First_WID.Contains(DataTable.Rows[i]["Wafer_ID"].ToString()))
@@ -388,10 +443,10 @@ namespace UAS_LabelMachine
                         if (i / PageSize >= 1 && i % PageSize == 0)
                         {
                             DataRow dr = FirstDT.NewRow();
-                            dr["型号"] = DataTable.Rows[i]["型号"].ToString();
-                            dr["出货单号"] = DataTable.Rows[i]["出货单号"].ToString();
-                            dr["客户"] = DataTable.Rows[i]["客户"].ToString();
-                            dr["销售日期"] = DataTable.Rows[i]["销售日期"].ToString();
+                            dr["pr_spec"] = DataTable.Rows[i]["pr_spec"].ToString();
+                            dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
+                            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_spec"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
@@ -436,12 +491,12 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_title"].ToString());
                                     }
                                     else if (j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
                                     }
                                     else
                                     {
@@ -457,12 +512,12 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["型号"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pr_spec"].ToString());
                                     }
                                     else if (j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["销售日期"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
                                     }
                                     else
                                     {
@@ -486,7 +541,7 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     //如果chw_itemname1的值为空,则值为100和0,其中一列不显示,不显示
                                     if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
@@ -504,25 +559,26 @@ namespace UAS_LabelMachine
                             row1.CreateCell(j - 4);
                             row1.Cells[j - 4].SetCellValue(Data);
                             row1.GetCell(j - 4).CellStyle = styleborder;
-                            if (DataTable.Columns[j].ColumnName == "数量")
+                            if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 sumCount += int.Parse(DataTable.Rows[i][j].ToString());
                                 totalCount += int.Parse(DataTable.Rows[i][j].ToString());
                             }
-                            if (DataTable.Columns[j].ColumnName == "序号")
+                            if (DataTable.Columns[j].ColumnName == "rownum")
                             {
                                 row1.Cells[j - 4].SetCellValue(i + 1);
                             }
                         }
+                        //固定行号分组的时候自动拼接新的DataTable
                         if (i == rowNum - 1)
                         {
                             DataRow dr = FirstDT.NewRow();
-                            dr["型号"] = DataTable.Rows[i]["型号"].ToString();
-                            dr["出货单号"] = DataTable.Rows[i]["出货单号"].ToString();
-                            dr["客户"] = DataTable.Rows[i]["客户"].ToString();
-                            dr["销售日期"] = DataTable.Rows[i]["销售日期"].ToString();
+                            dr["pr_spec"] = DataTable.Rows[i]["pr_spec"].ToString();
+                            dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
+                            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_spec"] = First_Prspec;
+                            dr["pr_spec1"] = First_Prspec;
                             dr["ch_splitbatch"] = First_Batch;
                             dr["ch_waterid"] = BaseUtil.GetArrStr(First_WID, " ");
                             dr["num"] = (i % PageSize) + 1;
@@ -599,7 +655,7 @@ namespace UAS_LabelMachine
                         PaintIndex = PaintIndex + 1;
                         row1.HeightInPoints = 20;
                         //如果批号不相等的时候
-                        if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["扩散批号"].ToString())
+                        if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString())
                         {
                             for (int j = 0; j < columnNum - 4; j++)
                             {
@@ -624,9 +680,9 @@ namespace UAS_LabelMachine
                             PaintIndex = PaintIndex + 1;
                         }
                         //每次到了页数开始分页
-                        if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["扩散批号"].ToString()) || i == rowNum - 1)
+                        if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString()) || i == rowNum - 1)
                         {
-                            LastBatchCode = DataTable.Rows[i]["扩散批号"].ToString();
+                            LastBatchCode = DataTable.Rows[i]["ch_splitbatch"].ToString();
                             //第一行添加客户信息
                             if (i != rowNum - 1)
                             {
@@ -635,12 +691,12 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_title"].ToString());
                                     }
                                     else if (j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
                                     }
                                     else
                                     {
@@ -685,7 +741,7 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
                                         sheet.SetColumnHidden(j - 4, true);
@@ -821,12 +877,12 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_title"].ToString());
                                     }
                                     else if (j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
                                     }
                                     else
                                     {
@@ -842,12 +898,12 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["型号"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pr_spec"].ToString());
                                     }
                                     else if (j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["销售日期"].ToString());
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
                                     }
                                     else
                                     {
@@ -860,6 +916,7 @@ 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")
@@ -871,7 +928,7 @@ namespace UAS_LabelMachine
                                         row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
                                     }
                                     else
-                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
                                     if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
                                         sheet.SetColumnHidden(j - 4, true);
@@ -888,12 +945,12 @@ namespace UAS_LabelMachine
                             row1.CreateCell(j - 4);
                             row1.Cells[j - 4].SetCellValue(Data);
                             row1.GetCell(j - 4).CellStyle = styleborder;
-                            if (DataTable.Columns[j].ColumnName == "数量")
+                            if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 sumCount += int.Parse(DataTable.Rows[i][j].ToString());
                                 totalCount += int.Parse(DataTable.Rows[i][j].ToString());
                             }
-                            if (DataTable.Columns[j].ColumnName == "序号")
+                            if (DataTable.Columns[j].ColumnName == "rownum")
                             {
                                 row1.Cells[j - 4].SetCellValue(i + 1);
                             }
@@ -975,35 +1032,65 @@ namespace UAS_LabelMachine
             row.Cells[0].SetCellValue("                     深爱半导体有限公司芯片出货清单");
             row.GetCell(0).CellStyle = style;
             rowNum = FirstDT.Rows.Count;
-            columnNum = FirstDT.Columns.Count;
+            //不需要显示的列移除
 
-            for (int i = 0; i < columnNum; i++)
+            for (int i = FirstDT.Columns.Count - 1; i > 0; i--)
             {
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pd_ordercode"))
+                for (int j = 0; j < box.Length; j++)
                 {
-                    FirstDT.Columns[i].ColumnName = "订单号";
-                }
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pr_spec"))
-                {
-                    FirstDT.Columns[i].ColumnName = "产品型号";
-                }
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
-                {
-                    FirstDT.Columns[i].ColumnName = "批号";
-                }
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
-                {
-                    FirstDT.Columns[i].ColumnName = "片号";
-                }
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("num"))
-                {
-                    FirstDT.Columns[i].ColumnName = "片数";
-                }
-                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("io_qty"))
-                {
-                    FirstDT.Columns[i].ColumnName = "管芯数";
+                    if (box[j].Name == "FirstPage_WID" && !box[j].Checked)
+                    {
+                        if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
+
+                        {
+                            FirstDT.Columns.RemoveAt(i);
+                        }
+                    }
+                    if (box[j].Name == "FirstPage_YIELD")
+                    {
+                        if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_yeild"))
+                        {
+                            FirstDT.Columns.RemoveAt(i);
+                        }
+                    }
+                    if (box[j].Name == "FirstPage_REMARK")
+                    {
+                        if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_remark"))
+                        {
+                            FirstDT.Columns.RemoveAt(i);
+                        }
+                    }
                 }
             }
+            columnNum = FirstDT.Columns.Count;
+
+            //for (int i = 0; i < columnNum; i++)
+            //{
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pd_ordercode"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "订单号";
+            //    }
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pr_spec"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "产品型号";
+            //    }
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "批号";
+            //    }
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "片号";
+            //    }
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("num"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "片数";
+            //    }
+            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("io_qty"))
+            //    {
+            //        FirstDT.Columns[i].ColumnName = "管芯数";
+            //    }
+            //}
 
             for (int i = 0; i < rowNum; i++)
             {
@@ -1018,12 +1105,12 @@ namespace UAS_LabelMachine
                         if (j == 0)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["客户"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_title"].ToString());
                         }
                         else if (j == columnNum - 4)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["出货单号"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_inoutno"].ToString());
                         }
                         else
                         {
@@ -1039,12 +1126,12 @@ namespace UAS_LabelMachine
                         if (j == 0)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["型号"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pr_spec"].ToString());
                         }
                         else if (j == columnNum - 4)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["销售日期"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_date"].ToString());
                         }
                         else
                         {
@@ -1059,7 +1146,7 @@ namespace UAS_LabelMachine
                     {
                         row1.CreateCell(j - 4);
                         row1.Cells[j - 4].CellStyle = styleborder;
-                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].ColumnName);
+                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
                     }
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
@@ -1071,11 +1158,11 @@ namespace UAS_LabelMachine
                     row1.CreateCell(j - 4);
                     row1.Cells[j - 4].SetCellValue(Data);
                     row1.GetCell(j - 4).CellStyle = styleborder;
-                    if (FirstDT.Columns[j].ColumnName == "片数")
+                    if (FirstDT.Columns[j].ColumnName == "num")
                     {
                         sumCount += int.Parse(Data);
                     }
-                    if (FirstDT.Columns[j].ColumnName == "管芯数")
+                    if (FirstDT.Columns[j].ColumnName == "io_qty")
                     {
                         totalCount += int.Parse(Data);
                     }
@@ -1121,7 +1208,6 @@ namespace UAS_LabelMachine
                     sheet2.SetColumnWidth(i, sheet2.GetColumnWidth(i) + 1000);
                 }
             }
-
             //将book的内容写入内存流中返回
             book.Write(ms);
             return ms;