Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-kb/bf8720db45348c80b7bf99ba8db77ead to your computer and use it in GitHub Desktop.
Save aspose-com-kb/bf8720db45348c80b7bf99ba8db77ead to your computer and use it in GitHub Desktop.
Export Multiple Sheets of a Large Excel File to Separate CSV Files in C#. To learn more check our step by step guide in the following topic: https://kb.aspose.com/cells/net/how-to-export-large-excel-file-to-csv-in-c-sharp/.
using System;
//Add reference to Aspose.Cells for .NET API
//Use following namespaces to Export excel file to CSV
using Aspose.Cells;
namespace ExportLargeExcelFiletoCSV
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before exporting Excel file to CSV file format
//using Aspose.Cells for .NET
Aspose.Cells.License AsposeCellsLicense = new Aspose.Cells.License();
AsposeCellsLicense.SetLicense(@"c:\asposelicense\license.lic");
//For optimized memory usage for large excel file use
//MemoryPreference MemorySetting option
LoadOptions OptionsLoadingLargeExcelFile = new LoadOptions();
OptionsLoadingLargeExcelFile.MemorySetting = MemorySetting.MemoryPreference;
//Create an instance of Workbook class to load input large excel file
//Also pass the MemoryPreference load options to the constructor
Workbook ExportExcelToCSVWorkBook = new Workbook("Large_Excel_To_Export.xlsx", OptionsLoadingLargeExcelFile);
//To save multiple sheets in a workbook use following code
for (int SheetIndex = 0; SheetIndex < ExportExcelToCSVWorkBook.Worksheets.Count; SheetIndex++)
{
ExportExcelToCSVWorkBook.Worksheets.ActiveSheetIndex = SheetIndex;
ExportExcelToCSVWorkBook.Save("Exported_CSV_" + SheetIndex + ".csv", SaveFormat.Csv);
}
}
}
}
@aspose-com-kb
Copy link
Author

To learn more check our step by step guide in the following topic: How to Export Large Excel File to CSV in C#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment