diff --git a/Excely.EPPlus.LGPL/Plugins/ErrorRecordPluginExtention.cs b/Excely.EPPlus.LGPL/Plugins/ErrorRecordPluginExtention.cs new file mode 100644 index 0000000..9c4dce1 --- /dev/null +++ b/Excely.EPPlus.LGPL/Plugins/ErrorRecordPluginExtention.cs @@ -0,0 +1,26 @@ +using Excely.Plugins; +using OfficeOpenXml; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excely.EPPlus.LGPL.Plugins +{ + public static class ErrorRecordPluginExtention + { + public static ExcelWorksheet ExportToWorksheet(this ErrorRecordPlugin errorRecordPlugin, bool errorRowOnly) + { + if(errorRecordPlugin?.Table == null) + { + throw new ArgumentNullException(); + } + + for(int rowIndex = 0; rowIndex < errorRecordPlugin.Table.MaxRowCount; rowIndex++) + { + if(!errorRecordPlugin.Errors.Keys.Any(cell => cell.Row == row)) + } + } + } +} diff --git a/Excely.sln b/Excely.sln index e1d14a8..63fe4e6 100644 --- a/Excely.sln +++ b/Excely.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Excely.ClosedXML.UnitTests" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{05E1BF0C-B2F1-41C1-B5AB-52C001A3D557}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Debug", "Debug\Debug.csproj", "{7BCFF4FE-F23D-4BDC-8D32-E22148C29F08}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,10 @@ Global {075DACAA-3E1D-46E6-B094-0E119B56673B}.Debug|Any CPU.Build.0 = Debug|Any CPU {075DACAA-3E1D-46E6-B094-0E119B56673B}.Release|Any CPU.ActiveCfg = Release|Any CPU {075DACAA-3E1D-46E6-B094-0E119B56673B}.Release|Any CPU.Build.0 = Release|Any CPU + {7BCFF4FE-F23D-4BDC-8D32-E22148C29F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BCFF4FE-F23D-4BDC-8D32-E22148C29F08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BCFF4FE-F23D-4BDC-8D32-E22148C29F08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BCFF4FE-F23D-4BDC-8D32-E22148C29F08}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Excely/Plugins/ErrorRecordPlugin.cs b/Excely/Plugins/ErrorRecordPlugin.cs new file mode 100644 index 0000000..6b46083 --- /dev/null +++ b/Excely/Plugins/ErrorRecordPlugin.cs @@ -0,0 +1,19 @@ +namespace Excely.Plugins +{ + public class ErrorRecordPlugin + { + public ExcelyTable? Table { get; set; } + + public Dictionary Errors { get; set; } = new Dictionary(); + + public void DoAfterGetTable(ExcelyTable table) + { + Table = table; + } + + public void RecordError(CellLocation location, string errorMessage) + { + Errors[location] = errorMessage; + } + } +} diff --git a/Excely/TableConverters/ClassListTableConverter.cs b/Excely/TableConverters/ClassListTableConverter.cs index dbbfc98..cdc64a0 100644 --- a/Excely/TableConverters/ClassListTableConverter.cs +++ b/Excely/TableConverters/ClassListTableConverter.cs @@ -92,11 +92,11 @@ private IEnumerable ImportInternal(ExcelyTable table, Func ImportInternal(ExcelyTable table, Func { protected abstract ExcelyTable GetTable(TInput input); + public List> DoAfterGetTableCallbackList { get; set; } = new List>(); + /// /// 將資料匯入為物件列表。 /// @@ -23,6 +25,7 @@ public IEnumerable ToClassList( where TClass : class, new() { var table = GetTable(dataSource); + DoAfterGetTableCallbackList.ForEach(x => x.Invoke(table)); var converter = options == null ? new ClassListTableConverter() : new ClassListTableConverter(options); return converter.ConvertFrom(table); } @@ -38,6 +41,7 @@ public IEnumerable ToClassList( DictionaryListTableConverterOptions? options = null) { var table = GetTable(dataSource); + DoAfterGetTableCallbackList.ForEach(x => x.Invoke(table)); var converter = options == null ? new DictionaryListTableConverter() : new DictionaryListTableConverter(options); return converter.ConvertFrom(table); }