diff --git a/ExcelMapper/ColumnInfo.cs b/ExcelMapper/ColumnInfo.cs index bfb2cbe..0b79a26 100644 --- a/ExcelMapper/ColumnInfo.cs +++ b/ExcelMapper/ColumnInfo.cs @@ -280,7 +280,7 @@ public virtual object GetProperty(object o) } /// Specifies a method to use when setting the cell value from an object. - /// The method to use when setting the cell value from an object. + /// The method to use when setting the cell value from an object. Action<cell: ICell, property: object> /// The object. public ColumnInfo SetCellUsing(Action setCell) { @@ -289,7 +289,7 @@ public ColumnInfo SetCellUsing(Action setCell) } /// Specifies a method to use when setting the cell value from an object. - /// The method to use when setting the cell value from an object. + /// The method to use when setting the cell value from an object. Action<cell: ICell, property: T> /// The object. public ColumnInfo SetCellUsing(Action setCell) { @@ -298,7 +298,7 @@ public ColumnInfo SetCellUsing(Action setCell) } /// Specifies a method to use when setting the property value from the cell value. - /// The method to use when setting the property value from the cell value. + /// The method to use when setting the property value from the cell value. Func<cellValue: object, out property: object> /// The object. public ColumnInfo SetPropertyUsing(Func setProp) { @@ -307,7 +307,7 @@ public ColumnInfo SetPropertyUsing(Func setProp) } /// Specifies a method to use when setting the property value from the cell value. - /// The method to use when setting the property value from the cell value. + /// The method to use when setting the property value from the cell value. Func<cellValue: object, cell: ICell, out property: object> /// The object. public ColumnInfo SetPropertyUsing(Func setProp) { diff --git a/ExcelMapper/ExcelMapper.cs b/ExcelMapper/ExcelMapper.cs index be532fe..b2f45f4 100644 --- a/ExcelMapper/ExcelMapper.cs +++ b/ExcelMapper/ExcelMapper.cs @@ -148,7 +148,7 @@ public ExcelMapper(Stream stream) /// The type of objects the Excel file is mapped to. /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, string sheetName, Func valueParser = null) { @@ -161,7 +161,7 @@ public IEnumerable Fetch(string file, string sheetName, FuncThe type of objects the Excel file is mapped to. /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, Type type, string sheetName, Func valueParser = null) { @@ -174,7 +174,7 @@ public IEnumerable Fetch(string file, Type type, string sheetName, Func /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, string sheetName, Func valueParser = null) { @@ -188,7 +188,7 @@ public IEnumerable Fetch(string file, string sheetName, FuncThe type of objects the Excel file is mapped to. /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, int sheetIndex, Func valueParser = null) { @@ -201,7 +201,7 @@ public IEnumerable Fetch(string file, int sheetIndex, FuncThe type of objects the Excel file is mapped to. /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, Type type, int sheetIndex, Func valueParser = null) { @@ -214,7 +214,7 @@ public IEnumerable Fetch(string file, Type type, int sheetIndex, Func /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(string file, int sheetIndex, Func valueParser = null) { @@ -228,7 +228,7 @@ public IEnumerable Fetch(string file, int sheetIndex, FuncThe type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, string sheetName, Func valueParser = null) { @@ -241,7 +241,7 @@ public IEnumerable Fetch(Stream stream, string sheetName, FuncThe type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, Type type, string sheetName, Func valueParser = null) { @@ -254,7 +254,7 @@ public IEnumerable Fetch(Stream stream, Type type, string sheetName, Func /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, string sheetName, Func valueParser = null) { @@ -268,7 +268,7 @@ public IEnumerable Fetch(Stream stream, string sheetName, FuncThe type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, int sheetIndex, Func valueParser = null) { @@ -281,7 +281,7 @@ public IEnumerable Fetch(Stream stream, int sheetIndex, FuncThe type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, Type type, int sheetIndex, Func valueParser = null) { @@ -294,7 +294,7 @@ public IEnumerable Fetch(Stream stream, Type type, int sheetIndex, Func /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Stream stream, int sheetIndex, Func valueParser = null) { @@ -307,7 +307,7 @@ public IEnumerable Fetch(Stream stream, int sheetIndex, Func /// The type of objects the Excel file is mapped to. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. /// Thrown when a sheet is not found public IEnumerable Fetch(string sheetName, Func valueParser = null) @@ -320,7 +320,7 @@ public IEnumerable Fetch(string sheetName, Func va /// /// The type of objects the Excel file is mapped to. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. /// Thrown when a sheet is not found public IEnumerable Fetch(Type type, string sheetName, Func valueParser = null) @@ -339,7 +339,7 @@ public IEnumerable Fetch(Type type, string sheetName, Func /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. /// Thrown when a sheet is not found public IEnumerable Fetch(string sheetName, Func valueParser = null) @@ -357,7 +357,7 @@ public IEnumerable Fetch(string sheetName, Func /// /// The type of objects the Excel file is mapped to. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(int sheetIndex = 0, Func valueParser = null) { @@ -370,7 +370,7 @@ public IEnumerable Fetch(int sheetIndex = 0, Func /// /// The type of objects the Excel file is mapped to /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(Type type, int sheetIndex = 0, Func valueParser = null) { @@ -384,7 +384,7 @@ public IEnumerable Fetch(Type type, int sheetIndex = 0, Func /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public IEnumerable Fetch(int sheetIndex = 0, Func valueParser = null) { @@ -573,7 +573,7 @@ private object MapCells(Type type, Func valueParser, Typ /// The type of objects the Excel file is mapped to. /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(string file, string sheetName, Func valueParser = null) { @@ -585,7 +585,7 @@ public async Task> FetchAsync(string file, string sheetName, F /// /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(string file, string sheetName, Func valueParser = null) { @@ -599,7 +599,7 @@ public async Task> FetchAsync(string file, string sheetName /// The type of objects the Excel file is mapped to. /// The path to the Excel file. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task FetchAsync(string file, Type type, string sheetName, Func valueParser = null) { @@ -613,7 +613,7 @@ public async Task FetchAsync(string file, Type type, string sheetNa /// The type of objects the Excel file is mapped to. /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(string file, int sheetIndex = 0, Func valueParser = null) { @@ -626,7 +626,7 @@ public async Task> FetchAsync(string file, int sheetIndex = 0, /// /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(string file, int sheetIndex = 0, Func valueParser = null) { @@ -640,7 +640,7 @@ public async Task> FetchAsync(string file, int sheetIndex = /// The type of objects the Excel file is mapped to. /// The path to the Excel file. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task FetchAsync(string file, Type type, int sheetIndex = 0, Func valueParser = null) { @@ -654,7 +654,7 @@ public async Task FetchAsync(string file, Type type, int sheetIndex /// The type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(Stream stream, string sheetName, Func valueParser = null) { @@ -667,7 +667,7 @@ public async Task> FetchAsync(Stream stream, string sheetName, /// /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(Stream stream, string sheetName, Func valueParser = null) { @@ -681,7 +681,7 @@ public async Task> FetchAsync(Stream stream, string sheetNa /// The type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Name of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task FetchAsync(Stream stream, Type type, string sheetName, Func valueParser = null) { @@ -695,7 +695,7 @@ public async Task FetchAsync(Stream stream, Type type, string sheet /// The type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(Stream stream, int sheetIndex = 0, Func valueParser = null) { @@ -708,7 +708,7 @@ public async Task> FetchAsync(Stream stream, int sheetIndex = /// /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task> FetchAsync(Stream stream, int sheetIndex = 0, Func valueParser = null) { @@ -722,7 +722,7 @@ public async Task> FetchAsync(Stream stream, int sheetIndex /// The type of objects the Excel file is mapped to. /// The stream the Excel file is read from. /// Index of the sheet. - /// Allow value parsing + /// Allow value parsing. Func<column(index/name): string, cellValue: object, out newCellValue: object> /// The objects read from the Excel file. public async Task FetchAsync(Stream stream, Type type, int sheetIndex = 0, Func valueParser = null) { diff --git a/README.md b/README.md index e8cce2c..640c310 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,12 @@ A library to map [POCO](https://en.wikipedia.org/wiki/Plain_Old_CLR_Object) obje ## Read objects from an Excel file ```C# -var products = new ExcelMapper("products.xlsx").Fetch(); +var products = new ExcelMapper("products.xlsx").Fetch(); // Read from first worksheet +var products = new ExcelMapper("products.xlsx").Fetch(2); // Read from third worksheet +var products = new ExcelMapper("products.xlsx").Fetch("Sheet Name"); // Read from specified worksheet name ``` -This expects the Excel file to contain a header row with the column names. Objects are read from the first worksheet. If the column names equal the property names (ignoring case) no other configuration is necessary. The format of the Excel file (xlsx or xls) is autodetected. +This expects the Excel file to contain a header row with the column names. Objects are read from the worksheet specified by index or name. If the column names equal the property names (ignoring case) no other configuration is necessary. The format of the Excel file (xlsx or xls) is autodetected. ## Map to specific column names