Class NpoiExtensions
Inheritance
Inherited Members
Namespace: WeihanLi.Npoi
Assembly: cs.temp.dll.dll
Syntax
public static class NpoiExtensions
Methods
GetCellCollection(IRow)
Get Row Cell Collection
Declaration
public static NpoiCellCollection GetCellCollection(this IRow row)
Parameters
Type | Name | Description |
---|---|---|
IRow | row | excel sheet row |
Returns
Type | Description |
---|---|
NpoiCellCollection | row collection |
GetCellValue(Nullable<ICell>, Type, Nullable<IFormulaEvaluator>)
GetCellValue
Declaration
public static object GetCellValue(this ICell? cell, Type propertyType, IFormulaEvaluator? formulaEvaluator = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<ICell> | cell | cell |
System.Type | propertyType | propertyType |
System.Nullable<IFormulaEvaluator> | formulaEvaluator | formulaEvaluator |
Returns
Type | Description |
---|---|
System.Object | cellValue |
GetCellValue<T>(Nullable<ICell>, Nullable<IFormulaEvaluator>)
GetCellValue
Declaration
public static T GetCellValue<T>(this ICell? cell, IFormulaEvaluator? formulaEvaluator = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<ICell> | cell | cell |
System.Nullable<IFormulaEvaluator> | formulaEvaluator |
Returns
Type | Description |
---|---|
T | typed cell value |
Type Parameters
Name | Description |
---|---|
T | Type |
GetFormulaEvaluator(IWorkbook)
get workbook IFormulaEvaluator
Declaration
public static IFormulaEvaluator GetFormulaEvaluator(this IWorkbook workbook)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
Returns
Type | Description |
---|---|
IFormulaEvaluator |
GetPicturesAndPosition(ISheet)
get pictures with position in current sheet
Declaration
public static Dictionary<CellPosition, IPictureData> GetPicturesAndPosition(this ISheet sheet)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
Returns
Type | Description |
---|---|
Dictionary<CellPosition, IPictureData> |
GetRowCollection(ISheet)
Get Sheet Row Collection
Declaration
public static NpoiRowCollection GetRowCollection(this ISheet sheet)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | excel sheet |
Returns
Type | Description |
---|---|
NpoiRowCollection | row collection |
GetWorkbookWithAutoSplitSheet(DataTable, ExcelFormat, Nullable<ExcelSetting>)
GetWorkbookWithAutoSplitSheet
Declaration
public static IWorkbook GetWorkbookWithAutoSplitSheet(this DataTable dataTable, ExcelFormat excelFormat, ExcelSetting? excelSetting = null)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
ExcelFormat | excelFormat | excel format |
System.Nullable<ExcelSetting> | excelSetting | excelSetting |
Returns
Type | Description |
---|---|
IWorkbook | excel workbook with data |
GetWorkbookWithAutoSplitSheet<TEntity>(IList<TEntity>, ExcelFormat)
GetWorkbookWithAutoSplitSheet
Declaration
public static IWorkbook GetWorkbookWithAutoSplitSheet<TEntity>(this IList<TEntity> entityList, ExcelFormat excelFormat)
Parameters
Type | Name | Description |
---|---|---|
IList<TEntity> | entityList | entity list |
ExcelFormat | excelFormat | excel format |
Returns
Type | Description |
---|---|
IWorkbook | excel workbook with data |
Type Parameters
Name | Description |
---|---|
TEntity | entity type |
ImportData(ISheet, Nullable<DataTable>)
Import dataTable data
Declaration
public static void ImportData(this ISheet sheet, DataTable? dataTable)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
System.Nullable<DataTable> | dataTable | dataTable |
ImportData<TEntity>(ISheet, DataTable)
import dataTable to sheet
Declaration
public static ISheet ImportData<TEntity>(this ISheet sheet, DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
DataTable | dataTable | dataTable |
Returns
Type | Description |
---|---|
ISheet |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ImportData<TEntity>(ISheet, DataTable, Int32)
import dataTable to sheet
Declaration
public static ISheet ImportData<TEntity>(this ISheet sheet, DataTable dataTable, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
DataTable | dataTable | dataTable |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
ISheet |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ImportData<TEntity>(ISheet, IEnumerable<TEntity>)
import entityList to sheet
Declaration
public static ISheet ImportData<TEntity>(this ISheet sheet, IEnumerable<TEntity> list)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
IEnumerable<TEntity> | list | entityList |
Returns
Type | Description |
---|---|
ISheet |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ImportData<TEntity>(ISheet, IEnumerable<TEntity>, Int32)
import entityList to sheet
Declaration
public static ISheet ImportData<TEntity>(this ISheet sheet, IEnumerable<TEntity> list, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
IEnumerable<TEntity> | list | entityList |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
ISheet |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ImportData<TEntity>(IWorkbook, DataTable)
import dataTable to workbook first sheet
Declaration
public static int ImportData<TEntity>(this IWorkbook workbook, DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
DataTable | dataTable | dataTable |
Returns
Type | Description |
---|---|
System.Int32 |
Type Parameters
Name | Description |
---|---|
TEntity | TEntity |
ImportData<TEntity>(IWorkbook, DataTable, Int32)
import dataTable to workbook first sheet
Declaration
public static int ImportData<TEntity>(this IWorkbook workbook, DataTable dataTable, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
DataTable | dataTable | dataTable |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
System.Int32 | the sheet LastRowNum |
Type Parameters
Name | Description |
---|---|
TEntity | TEntity |
ImportData<TEntity>(IWorkbook, IEnumerable<TEntity>)
import entityList to workbook first sheet
Declaration
public static int ImportData<TEntity>(this IWorkbook workbook, IEnumerable<TEntity> list)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
IEnumerable<TEntity> | list | entityList |
Returns
Type | Description |
---|---|
System.Int32 |
Type Parameters
Name | Description |
---|---|
TEntity | TEntity |
ImportData<TEntity>(IWorkbook, IEnumerable<TEntity>, Int32)
import entityList to workbook sheet
Declaration
public static int ImportData<TEntity>(this IWorkbook workbook, IEnumerable<TEntity> list, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
IEnumerable<TEntity> | list | entityList |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
System.Int32 | the sheet LastRowNum |
Type Parameters
Name | Description |
---|---|
TEntity | TEntity |
SetCellValue(ICell, Object)
SetCellValue
Declaration
public static void SetCellValue(this ICell cell, object value)
Parameters
Type | Name | Description |
---|---|---|
ICell | cell | ICell |
System.Object | value | value |
SetCellValue(ICell, Object, String)
SetCellValue
Declaration
public static void SetCellValue(this ICell cell, object value, string formatter)
Parameters
Type | Name | Description |
---|---|---|
ICell | cell | ICell |
System.Object | value | value |
System.String | formatter | formatter |
ToDataSet(IWorkbook, Boolean, Nullable<Int32>)
Workbook2ToDataSet
Declaration
public static DataSet ToDataSet(this IWorkbook workbook, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataSet | DataSet |
ToDataSet(IWorkbook, Int32, Boolean, Nullable<Int32>)
Workbook2ToDataSet
Declaration
public static DataSet ToDataSet(this IWorkbook workbook, int headerRowIndex, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
System.Int32 | headerRowIndex | headerRowIndex |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataSet | DataSet |
ToDataTable(ISheet, Boolean, Nullable<Int32>)
Sheet2DataTable
Declaration
public static DataTable ToDataTable(this ISheet sheet, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | excel sheet |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataTable | DataTable |
ToDataTable(ISheet, Int32, Boolean, Nullable<Int32>)
Sheet2DataTable
Declaration
public static DataTable ToDataTable(this ISheet sheet, int headerRowIndex, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | excel sheet |
System.Int32 | headerRowIndex | headerRowIndex |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataTable | DataTable |
ToDataTable(IWorkbook, Boolean, Nullable<Int32>)
Workbook2ToDataTable
Declaration
public static DataTable ToDataTable(this IWorkbook workbook, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataTable | DataTable |
ToDataTable(IWorkbook, Int32, Int32, Boolean, Nullable<Int32>)
Workbook2ToDataTable
Declaration
public static DataTable ToDataTable(this IWorkbook workbook, int sheetIndex, int headerRowIndex, bool removeEmptyRows = false, int? maxColumns = null)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
System.Int32 | sheetIndex | sheetIndex |
System.Int32 | headerRowIndex | headerRowIndex |
System.Boolean | removeEmptyRows | removeEmptyRows |
System.Nullable<System.Int32> | maxColumns | maxColumns |
Returns
Type | Description |
---|---|
DataTable | DataTable |
ToEntityList<TEntity>(ISheet)
Sheet2EntityList
Declaration
public static List<TEntity> ToEntityList<TEntity>(this ISheet sheet)
where TEntity : new()
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | excel sheet |
Returns
Type | Description |
---|---|
List<TEntity> | entity list |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToEntityList<TEntity>(ISheet, Int32)
Sheet2EntityList
Declaration
public static List<TEntity> ToEntityList<TEntity>(this ISheet sheet, int sheetIndex)
where TEntity : new()
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | excel sheet |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
List<TEntity> | entity list |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToEntityList<TEntity>(IWorkbook)
Workbook2EntityList
Declaration
public static List<TEntity> ToEntityList<TEntity>(this IWorkbook workbook)
where TEntity : new()
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
Returns
Type | Description |
---|---|
List<TEntity> | entity list |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToEntityList<TEntity>(IWorkbook, Int32)
Workbook2EntityList
Declaration
public static List<TEntity> ToEntityList<TEntity>(this IWorkbook workbook, int sheetIndex)
where TEntity : new()
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | excel workbook |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
List<TEntity> | entity list |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelBytes(DataTable)
DataTable2ExcelBytes(*.xlsx by default)
Declaration
public static byte[] ToExcelBytes(this DataTable dataTable)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
Returns
Type | Description |
---|---|
System.Byte[] |
ToExcelBytes(DataTable, ExcelFormat)
DataTable2ExcelBytes
Declaration
public static byte[] ToExcelBytes(this DataTable dataTable, ExcelFormat excelFormat)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
ExcelFormat | excelFormat | excel格式 |
Returns
Type | Description |
---|---|
System.Byte[] |
ToExcelBytes(DataTable, ExcelFormat, Nullable<ExcelSetting>)
DataTable2ExcelBytes
Declaration
public static byte[] ToExcelBytes(this DataTable dataTable, ExcelFormat excelFormat, ExcelSetting? excelSetting)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
ExcelFormat | excelFormat | excelFormat |
System.Nullable<ExcelSetting> | excelSetting | excelSetting |
Returns
Type | Description |
---|---|
System.Byte[] |
ToExcelBytes(IWorkbook)
ToExcelBytes
Declaration
public static byte[] ToExcelBytes(this IWorkbook workbook)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
Returns
Type | Description |
---|---|
System.Byte[] | excel bytes |
ToExcelBytes<TEntity>(IEnumerable<TEntity>)
EntityList2ExcelBytes(*.xls by default)
Declaration
public static byte[] ToExcelBytes<TEntity>(this IEnumerable<TEntity> entityList)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
Returns
Type | Description |
---|---|
System.Byte[] |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelBytes<TEntity>(IEnumerable<TEntity>, ExcelFormat)
EntityList2ExcelBytes
Declaration
public static byte[] ToExcelBytes<TEntity>(this IEnumerable<TEntity> entityList, ExcelFormat excelFormat)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
ExcelFormat | excelFormat | excelFormat |
Returns
Type | Description |
---|---|
System.Byte[] |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelBytes<TEntity>(IEnumerable<TEntity>, ExcelFormat, Int32)
EntityList2ExcelBytes
Declaration
public static byte[] ToExcelBytes<TEntity>(this IEnumerable<TEntity> entityList, ExcelFormat excelFormat, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
ExcelFormat | excelFormat | excelFormat |
System.Int32 | sheetIndex | sheetIndex |
Returns
Type | Description |
---|---|
System.Byte[] |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelBytes<TEntity>(IList<TEntity>, ExcelFormat)
EntityList2ExcelBytes
Declaration
public static byte[] ToExcelBytes<TEntity>(this IList<TEntity> entityList, ExcelFormat excelFormat = ExcelFormat.Xls)
Parameters
Type | Name | Description |
---|---|---|
IList<TEntity> | entityList | entityList |
ExcelFormat | excelFormat | excelFormat |
Returns
Type | Description |
---|---|
System.Byte[] |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelBytesByTemplate<TEntity>(IEnumerable<TEntity>, ISheet, Object)
export excel via template
Declaration
public static byte[] ToExcelBytesByTemplate<TEntity>(this IEnumerable<TEntity> entities, ISheet templateSheet, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
ISheet | templateSheet | |
System.Object | extraData | extraData |
Returns
Type | Description |
---|---|
System.Byte[] | exported excel bytes |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelBytesByTemplate<TEntity>(IEnumerable<TEntity>, IWorkbook, Int32, Object)
export excel via template
Declaration
public static byte[] ToExcelBytesByTemplate<TEntity>(this IEnumerable<TEntity> entities, IWorkbook templateWorkbook, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
IWorkbook | templateWorkbook | templateWorkbook |
System.Int32 | sheetIndex | sheetIndex |
System.Object | extraData | extraData |
Returns
Type | Description |
---|---|
System.Byte[] | exported excel bytes |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelBytesByTemplate<TEntity>(IEnumerable<TEntity>, Stream, ExcelFormat, Int32, Object)
export excel via template
Declaration
public static byte[] ToExcelBytesByTemplate<TEntity>(this IEnumerable<TEntity> entities, Stream templateStream, ExcelFormat excelFormat = ExcelFormat.Xls, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
Stream | templateStream | templateStream |
ExcelFormat | excelFormat | excelFormat |
System.Int32 | sheetIndex | sheetIndex,zero by default |
System.Object | extraData | extraData |
Returns
Type | Description |
---|---|
System.Byte[] | exported excel bytes |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelBytesByTemplate<TEntity>(IEnumerable<TEntity>, Byte[], ExcelFormat, Int32, Object)
export excel via template
Declaration
public static byte[] ToExcelBytesByTemplate<TEntity>(this IEnumerable<TEntity> entities, byte[] templateBytes, ExcelFormat excelFormat = ExcelFormat.Xls, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
System.Byte[] | templateBytes | templateBytes |
ExcelFormat | excelFormat | excelFormat |
System.Int32 | sheetIndex | sheetIndex,zero by default |
System.Object | extraData | extraData |
Returns
Type | Description |
---|---|
System.Byte[] | exported excel bytes |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelBytesByTemplate<TEntity>(IEnumerable<TEntity>, String, Int32, Object)
export excel via template
Declaration
public static byte[] ToExcelBytesByTemplate<TEntity>(this IEnumerable<TEntity> entities, string templatePath, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
System.String | templatePath | templatePath |
System.Int32 | sheetIndex | sheetIndex,zero by default |
System.Object | extraData | extraData |
Returns
Type | Description |
---|---|
System.Byte[] | exported excel bytes |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelFile(DataTable, String)
export DataTable to excel file
Declaration
public static void ToExcelFile(this DataTable dataTable, string excelPath)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
System.String | excelPath | excelPath |
ToExcelFile(DataTable, String, Nullable<ExcelSetting>)
export DataTable to excel file
Declaration
public static void ToExcelFile(this DataTable dataTable, string excelPath, ExcelSetting? excelSetting)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
System.String | excelPath | excelPath |
System.Nullable<ExcelSetting> | excelSetting | excelSetting |
ToExcelFile<TEntity>(IEnumerable<TEntity>, String)
EntityList2ExcelFile
Declaration
public static void ToExcelFile<TEntity>(this IEnumerable<TEntity> entityList, string excelPath)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
System.String | excelPath | excelPath |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelFile<TEntity>(IEnumerable<TEntity>, String, Int32)
EntityList2ExcelFile
Declaration
public static void ToExcelFile<TEntity>(this IEnumerable<TEntity> entityList, string excelPath, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
System.String | excelPath | excelPath |
System.Int32 | sheetIndex | sheetIndex |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelFile<TEntity>(IList<TEntity>, String)
EntityList2ExcelFile
Declaration
public static void ToExcelFile<TEntity>(this IList<TEntity> entityList, string excelPath)
Parameters
Type | Name | Description |
---|---|---|
IList<TEntity> | entityList | entityList |
System.String | excelPath | excelPath |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelFileByTemplate<TEntity>(IEnumerable<TEntity>, IWorkbook, String, Int32, Object)
export excel via template
Declaration
public static void ToExcelFileByTemplate<TEntity>(this IEnumerable<TEntity> entities, IWorkbook templateWorkbook, string excelPath, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
IWorkbook | templateWorkbook | templateWorkbook |
System.String | excelPath | |
System.Int32 | sheetIndex | sheetIndex |
System.Object | extraData | extraData |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelFileByTemplate<TEntity>(IEnumerable<TEntity>, Byte[], String, ExcelFormat, Int32, Object)
export excel via template
Declaration
public static void ToExcelFileByTemplate<TEntity>(this IEnumerable<TEntity> entities, byte[] templateBytes, string excelPath, ExcelFormat excelFormat = ExcelFormat.Xls, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
System.Byte[] | templateBytes | templateBytes |
System.String | excelPath | excelPath |
ExcelFormat | excelFormat | excelFormat |
System.Int32 | sheetIndex | sheetIndex,zero by default |
System.Object | extraData | extraData |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelFileByTemplate<TEntity>(IEnumerable<TEntity>, String, String, Int32, Object)
export excel via template
Declaration
public static void ToExcelFileByTemplate<TEntity>(this IEnumerable<TEntity> entities, string templatePath, string excelPath, int sheetIndex = 0, object extraData = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | entities |
System.String | templatePath | |
System.String | excelPath | templateBytes |
System.Int32 | sheetIndex | sheetIndex,zero by default |
System.Object | extraData | extraData |
Type Parameters
Name | Description |
---|---|
TEntity | Entity Type |
ToExcelStream(DataTable, Stream)
DataTable2ExcelStream
Declaration
public static void ToExcelStream(this DataTable dataTable, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
Stream | stream | stream |
ToExcelStream(DataTable, Stream, ExcelFormat)
DataTable2ExcelStream
Declaration
public static void ToExcelStream(this DataTable dataTable, Stream stream, ExcelFormat excelFormat)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
Stream | stream | stream |
ExcelFormat | excelFormat | excelFormat |
ToExcelStream(DataTable, Stream, ExcelFormat, Nullable<ExcelSetting>)
DataTable2ExcelStream
Declaration
public static void ToExcelStream(this DataTable dataTable, Stream stream, ExcelFormat excelFormat, ExcelSetting? excelSetting)
Parameters
Type | Name | Description |
---|---|---|
DataTable | dataTable | dataTable |
Stream | stream | stream |
ExcelFormat | excelFormat | excelFormat |
System.Nullable<ExcelSetting> | excelSetting | excelSetting |
ToExcelStream<TEntity>(IEnumerable<TEntity>, Stream)
EntityList2ExcelStream(*.xls by default)
Declaration
public static void ToExcelStream<TEntity>(this IEnumerable<TEntity> entityList, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
Stream | stream | stream where to write |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelStream<TEntity>(IEnumerable<TEntity>, Stream, ExcelFormat)
EntityList2ExcelStream
Declaration
public static void ToExcelStream<TEntity>(this IEnumerable<TEntity> entityList, Stream stream, ExcelFormat excelFormat)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
Stream | stream | stream where to write |
ExcelFormat | excelFormat | excelFormat |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelStream<TEntity>(IEnumerable<TEntity>, Stream, ExcelFormat, Int32)
EntityList2ExcelStream
Declaration
public static void ToExcelStream<TEntity>(this IEnumerable<TEntity> entityList, Stream stream, ExcelFormat excelFormat, int sheetIndex)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entityList | entityList |
Stream | stream | stream where to write |
ExcelFormat | excelFormat | excelFormat |
System.Int32 | sheetIndex | sheetIndex |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
ToExcelStream<TEntity>(IList<TEntity>, Stream, ExcelFormat)
EntityList2ExcelStream
Declaration
public static void ToExcelStream<TEntity>(this IList<TEntity> entityList, Stream stream, ExcelFormat excelFormat = ExcelFormat.Xls)
Parameters
Type | Name | Description |
---|---|---|
IList<TEntity> | entityList | entityList |
Stream | stream | stream where to write |
ExcelFormat | excelFormat | excelFormat |
Type Parameters
Name | Description |
---|---|
TEntity | EntityType |
TryAddPicture(ISheet, Int32, Int32, IPictureData)
TryAddPicture in specific cell
Declaration
public static bool TryAddPicture(this ISheet sheet, int row, int col, IPictureData pictureData)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
System.Int32 | row | cell rowIndex |
System.Int32 | col | cell columnIndex |
IPictureData | pictureData | pictureData |
Returns
Type | Description |
---|---|
System.Boolean | whether add success |
TryAddPicture(ISheet, Int32, Int32, Byte[], PictureType)
TryAddPicture in specific cell
Declaration
public static bool TryAddPicture(this ISheet sheet, int row, int col, byte[] pictureBytes, PictureType pictureType = null)
Parameters
Type | Name | Description |
---|---|---|
ISheet | sheet | sheet |
System.Int32 | row | cell rowIndex |
System.Int32 | col | cell columnIndex |
System.Byte[] | pictureBytes | picture bytes |
PictureType | pictureType | picture type |
Returns
Type | Description |
---|---|
System.Boolean | whether add success |
WriteToFile(IWorkbook, String)
Write workbook to excel file
Declaration
public static void WriteToFile(this IWorkbook workbook, string filePath)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | workbook |
System.String | filePath | file path |