Commit 189af943 by lcx

首次抽取时,起始行列位置错误调整

parent f184f938
...@@ -34,17 +34,18 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType ...@@ -34,17 +34,18 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
// 去除excel中已存在的列 // 去除excel中已存在的列
int headerFirstCellNum = point.DataFirstCellNum.Value; int headerFirstCellNum = point.DataFirstCellNum.Value;
if (columnHeader.LastCellNum > point.DataFirstCellNum) if (columnHeader.LastCellNum > point.DataFirstCellNum.Value)
{ {
for (int index = headerFirstCellNum; index < columnHeader.LastCellNum; index++) for (int index = point.DataFirstCellNum.Value; index < columnHeader.LastCellNum; index++)
{ {
var column = columnHeader.GetCell(index).GetDecodeEscapes(); var column = columnHeader.GetCell(index).GetDecodeEscapes();
if (string.IsNullOrEmpty(column)) continue; if (string.IsNullOrEmpty(column)) continue;
if (index > headerFirstCellNum) headerFirstCellNum = index;
columns.RemoveAll(t => t.ColumnName.NoBlank() == column); columns.RemoveAll(t => t.ColumnName.NoBlank() == column);
if (index > headerFirstCellNum)
headerFirstCellNum = index + 1;
} }
if (headerFirstCellNum > point.DataFirstCellNum.Value)
headerFirstCellNum += 1;
} }
if (columns == null || !columns.Any()) return; if (columns == null || !columns.Any()) return;
...@@ -53,7 +54,6 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType ...@@ -53,7 +54,6 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
: style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.系数, CellFormat.百分比); : style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.系数, CellFormat.百分比);
var columnStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头); var columnStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头);
headerFirstCellNum += 1;
// 补充excel中不存在的列 // 补充excel中不存在的列
foreach (var item in columns) foreach (var item in columns)
{ {
...@@ -111,7 +111,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -111,7 +111,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
int dataFirstCellNum = point.DataFirstCellNum.Value; int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++) for (int rowIndex = point.DataFirstRowNum.Value; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{ {
var row = sheet.GetRow(rowIndex); var row = sheet.GetRow(rowIndex);
if (row == null) continue; if (row == null) continue;
...@@ -119,6 +119,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -119,6 +119,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes(); string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue; if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex;
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue; if (deptData == null || !deptData.Any()) continue;
...@@ -146,8 +148,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -146,8 +148,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
} }
data.RemoveAll(t => t.Department == department); data.RemoveAll(t => t.Department == department);
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
} }
dataFirstRowNum += 1;
} }
private static void WriteSheetDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style, private static void WriteSheetDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style,
...@@ -166,7 +168,6 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -166,7 +168,6 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
headers = headers.Select(t => t.NoBlank()).ToList(); headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1;
foreach (string department in departments) foreach (string department in departments)
{ {
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
...@@ -266,7 +267,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -266,7 +267,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
int dataFirstCellNum = point.DataFirstCellNum.Value; int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++) for (int rowIndex = point.DataFirstRowNum.Value; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{ {
var row = sheet.GetRow(rowIndex); var row = sheet.GetRow(rowIndex);
if (row == null) continue; if (row == null) continue;
...@@ -274,6 +275,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -274,6 +275,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes(); string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue; if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex;
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue; if (deptData == null || !deptData.Any()) continue;
...@@ -300,8 +303,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -300,8 +303,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
} }
data.RemoveAll(t => t.Department == department); data.RemoveAll(t => t.Department == department);
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
} }
dataFirstRowNum += 1;
} }
private static void WriteCollectDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style, private static void WriteCollectDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style,
...@@ -318,7 +321,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -318,7 +321,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
headers = headers.Select(t => t.NoBlank()).ToList(); headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1;
foreach (string department in departments) foreach (string department in departments)
{ {
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment