Skip to content

Instantly share code, notes, and snippets.

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