Pārlūkot izejas kodu

优化右边距截取

callm 6 dienas atpakaļ
vecāks
revīzija
d0de0459f0
1 mainītis faili ar 12 papildinājumiem un 1 dzēšanām
  1. 12 1
      UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

+ 12 - 1
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

@@ -131,7 +131,18 @@ namespace UAS_MES_NEW.Query
                         string path = Application.StartupPath + @"\" + ps_prodcode.Text + @"\";
                         string path = Application.StartupPath + @"\" + ps_prodcode.Text + @"\";
                         Worksheet she = workbook.Worksheets[i];
                         Worksheet she = workbook.Worksheets[i];
                         // ---------- 基础参数 ----------
                         // ---------- 基础参数 ----------
-                        int lastColIndex = she.Cells.MaxDataColumn + 3;
+                        int contentMaxCol = she.Cells.MaxDataColumn;
+                        for (int p = 0; p < she.Pictures.Count; p++)
+                        {
+                            if (she.Pictures[p].LowerRightColumn > contentMaxCol)
+                                contentMaxCol = she.Pictures[p].LowerRightColumn;
+                        }
+                        for (int s = 0; s < she.Shapes.Count; s++)
+                        {
+                            if (she.Shapes[s].LowerRightColumn > contentMaxCol)
+                                contentMaxCol = she.Shapes[s].LowerRightColumn;
+                        }
+                        int lastColIndex = contentMaxCol;   // 额外留3列边距
                         string lastColLetter = CellsHelper.ColumnIndexToName(lastColIndex);
                         string lastColLetter = CellsHelper.ColumnIndexToName(lastColIndex);
                         const int headerRows = 3;
                         const int headerRows = 3;
                         int dataRowsPerPage = int.Parse(RowCount.Value.ToString());
                         int dataRowsPerPage = int.Parse(RowCount.Value.ToString());