From 666328245260b4b998b361e3a6827bf6fdfcec75 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 14 Feb 2024 17:37:50 +0900 Subject: [PATCH] fix --- ExcelHelper/ExcelHelperFW/ExcelHelper.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ExcelHelper/ExcelHelperFW/ExcelHelper.cs b/ExcelHelper/ExcelHelperFW/ExcelHelper.cs index 3118b77..6c6ed8f 100644 --- a/ExcelHelper/ExcelHelperFW/ExcelHelper.cs +++ b/ExcelHelper/ExcelHelperFW/ExcelHelper.cs @@ -25,7 +25,7 @@ namespace ExcelHelperFW /// copy path /// /// - public List> GetData(string sourcePath, string sheetName, bool removeHeader, int rowStartPosition = 1, string tempPath = "./temp_file.xlsx") + public List> GetData(string sourcePath, string sheetName, bool removeHeader, int rowStartPosition = 1, Func, bool> continueFunc = null, string tempPath = "./temp_file.xlsx") { File.Copy(sourcePath, tempPath, true); @@ -38,7 +38,7 @@ namespace ExcelHelperFW Sheet sheet = workbookPart.Workbook.Descendants().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); } }