Last active
July 5, 2021 11:40
-
-
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/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To learn more check our step by step guide in the following topic: How to Export Large Excel File to CSV in C#