|
|
|
@ -25,7 +25,7 @@ namespace ExcelHelperFW |
|
|
|
|
/// <param name="tempPath">copy path</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="Exception"></exception> |
|
|
|
|
public List<Dictionary<string, string>> GetData(string sourcePath, string sheetName, bool removeHeader, int rowStartPosition = 1, string tempPath = "./temp_file.xlsx") |
|
|
|
|
public List<Dictionary<string, string>> GetData(string sourcePath, string sheetName, bool removeHeader, int rowStartPosition = 1, Func<Dictionary<string, string>, bool> continueFunc = null, string tempPath = "./temp_file.xlsx") |
|
|
|
|
{ |
|
|
|
|
File.Copy(sourcePath, tempPath, true); |
|
|
|
|
|
|
|
|
@ -38,7 +38,7 @@ namespace ExcelHelperFW |
|
|
|
|
Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().FirstOrDefault(s => s.Name == sheetName); |
|
|
|
|
|
|
|
|
|
if (sheet == null) |
|
|
|
|
throw new Exception("Cannot find sheet."); |
|
|
|
|
throw new Exception($"Cannot find sheet. (Sheet name: {sheetName})"); |
|
|
|
|
|
|
|
|
|
WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id); |
|
|
|
|
Worksheet worksheet = worksheetPart.Worksheet; |
|
|
|
@ -53,6 +53,9 @@ namespace ExcelHelperFW |
|
|
|
|
if (rowPairs == null || rowPairs.Count < 1) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (continueFunc != null && continueFunc(rowPairs)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
data.Add(rowPairs); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|