Last active
August 18, 2021 13:31
-
-
Save GroupDocsGists/53e4d00e8195ad3eb4ba03fffc4e9315 to your computer and use it in GitHub Desktop.
Convert Excel Spreadsheets to CSV and CSV to XLS/XLSX using C#
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
// Convert CSV files to XLS/XLSX format in C# | |
string inputFile = @"path/comma-sparated-values.csv"; | |
string outputFile = @"path/spreadsheet.xlsx"; | |
Contracts.Func<LoadOptions> getLoadOptions = () => new CsvLoadOptions | |
{ | |
Separator = ',' | |
}; | |
using (Converter converter = new Converter(inputFile)) | |
{ | |
SpreadsheetConvertOptions options = new SpreadsheetConvertOptions(); | |
converter.Convert(outputFile, options); | |
} |
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
// Convert Excel Spreadsheets to Comma Separated Values CSV format in C# | |
string inputFile = @"path/spreadsheet.xlsx"; | |
string outputFile = @"path/comma-sparated-values.csv"; | |
using (Converter converter = new Converter(inputFile)) | |
{ | |
SpreadsheetConvertOptions options = new SpreadsheetConvertOptions | |
{ | |
PageNumber = 2, | |
PagesCount = 1, | |
Format = SpreadsheetFileType.Csv // Specify the conversion format | |
}; | |
converter.Convert(outputFile, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment