Exemple #1
0
        public static void SaveAs(this Stream stream, object value, bool printHeader = true, ExcelType excelType = ExcelType.XLSX)
        {
            switch (excelType)
            {
            case ExcelType.CSV:
                CsvWriter.SaveAs(stream, value);
                break;

            case ExcelType.XLSX:
                ExcelOpenXmlSheetWriter.SaveAs(stream, value, printHeader);
                break;

            default:
                throw new NotSupportedException($"Extension : {excelType} not suppprt");
            }
        }
Exemple #2
0
        public static void SaveAs(string filePath, object value, bool printHeader = true, ExcelType excelType = ExcelType.UNKNOWN)
        {
            if (excelType == ExcelType.UNKNOWN)
            {
                excelType = GetExcelType(filePath);
            }
            switch (excelType)
            {
            case ExcelType.CSV:
                CsvWriter.SaveAs(filePath, value);
                break;

            case ExcelType.XLSX:
                ExcelOpenXmlSheetWriter.SaveAs(filePath, value, printHeader);
                break;

            default:
                throw new NotSupportedException($"Extension : {Path.GetExtension(filePath)} not suppprt");
            }
        }