callm hace 4 semanas
padre
commit
8f59b33c7c
Se han modificado 1 ficheros con 26 adiciones y 3 borrados
  1. 26 3
      UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

+ 26 - 3
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

@@ -129,8 +129,8 @@ namespace UAS_MES_NEW.Query
                             Worksheet she = workbook.Worksheets[i];
 
                             // 获取原表的实际数据范围和最大列
-                            int totalRows = she.Cells.MaxDataRow + 1;
-                            int lastColIndex = she.Cells.MaxDataColumn;
+                            int totalRows = she.Cells.MaxDataRow;
+                            int lastColIndex = she.Cells.MaxDataColumn+5;
                             string lastColLetter = CellsHelper.ColumnIndexToName(lastColIndex);
 
                             int rowSliceSize = int.Parse(RowCount.Value.ToString());
@@ -157,7 +157,30 @@ namespace UAS_MES_NEW.Query
 
                                 // 1. 动态设置原表的打印区域(模拟切片)
                                 // 注意:这里直接使用原表渲染,虽然旧版本对图片的浮层处理有限,但这能最大程度保留图片
-                                she.PageSetup.PrintArea = $"A{startRow + 1}:{lastColLetter}{endRow + 1}";
+                                Console.WriteLine($"A1:{lastColLetter}{totalRows}");
+                                Console.WriteLine($"A{startRow + 1}:{lastColLetter}{endRow + 1}");
+                                if (endRow < rowSliceSize)
+                                {
+                                    she.PageSetup.PrintArea = $"A{startRow + 1}:{lastColLetter}{rowSliceSize + 1}";
+                                }
+                                else {
+                                    she.PageSetup.PrintArea = $"A{startRow + 1}:{lastColLetter}{endRow + 1}";
+                                }
+
+                                if (File.Exists(PrintPath.Text))
+                                {
+                                    if (startRow == 0)
+                                    {
+                                        she.Pictures.Add(startRow + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
+
+                                    }
+                                    else
+                                    {
+                                        she.Pictures.Add(startRow - 4 + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
+
+                                    }
+                                }
+
 
                                 // 2. 创建渲染选项
                                 ImageOrPrintOptions options = new ImageOrPrintOptions();