Skip to content

Instantly share code, notes, and snippets.

@groupdocs-com-kb
Last active April 1, 2022 17:03
Show Gist options
  • Save groupdocs-com-kb/a57b65aa6f15a7e9ceea41362ea61ea9 to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/a57b65aa6f15a7e9ceea41362ea61ea9 to your computer and use it in GitHub Desktop.
How to Convert Excel to CSV in C#. For more information, please follow link: https://kb.groupdocs.com/conversion/net/how-to-convert-excel-to-csv-in-csharp/
using System;
using GroupDocs.Conversion.Options.Convert;
namespace ConvertExcelToCsvInCSharp
{
class Program
{
public static void Main(string[] args) // Main function to convert Excel to CSV using C#
{
// Remove the watermark in output CSV document by adding license
string licensePath = "GroupDocs.Conversion.lic";
GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
lic.SetLicense(licensePath);
// Load the source Excel file for conversion to CSV
var converter = new GroupDocs.Conversion.Converter("sample.xlsx");
// Set the starting sheet number and consecutive sheet count
var convertOptions = new SpreadsheetConvertOptions
{
Format = GroupDocs.Conversion.FileTypes.SpreadsheetFileType.Csv,
PageNumber = 1,
PagesCount = 1
};
// Convert and save the Excel in CSV format
converter.Convert("converted.csv", convertOptions);
Console.WriteLine("Done");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment