Beispiel #1
0
 /// <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);
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 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();
 }
Beispiel #4
0
 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);
 }