/// <summary> /// Default SaveAs Xlsx file /// </summary> public static void SaveAs(this Stream stream, object value, bool printHeader = true, string sheetName = null, ExcelType excelType = ExcelType.XLSX, IConfiguration configuration = null) { if (excelType == ExcelType.UNKNOWN) { throw new InvalidDataException("Please specify excelType"); } ExcelWriterFactory.GetProvider(stream, excelType).SaveAs(value, printHeader, configuration); }
private static IExcelWriterAsync GetWriterProvider(Stream stream, string sheetName, ExcelType excelType) { if (string.IsNullOrEmpty(sheetName)) { throw new InvalidDataException("Sheet name can not be empty or null"); } if (excelType == ExcelType.UNKNOWN) { throw new InvalidDataException("Please specify excelType"); } return(ExcelWriterFactory.GetProvider(stream, excelType)); }
public static void SaveAs(this Stream stream, object value, bool printHeader = true, string sheetName = "Sheet1", ExcelType excelType = ExcelType.XLSX, IConfiguration configuration = null) { ExcelWriterFactory.GetProvider(stream, value, sheetName, excelType, configuration, printHeader).SaveAs(); }
public static async Task SaveAsAsync(this Stream stream, object value, bool printHeader = true, string sheetName = "Sheet1", ExcelType excelType = ExcelType.XLSX, IConfiguration configuration = null, CancellationToken cancellationToken = default(CancellationToken)) { await ExcelWriterFactory.GetProvider(stream, value, sheetName, excelType, configuration, printHeader).SaveAsAsync(cancellationToken); }