We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Trusted by the world’s leading companies

Syncfusion Trusted Companies

Overview

The Syncfusion .NET Excel (XlsIO) library offers comprehensive support for converting Excel to CSV format. It allows the creation of CSV documents from Excel documents in different formats such as xlsx, xls, xlsm, and xltm. Also, it supports saving CSV documents with customized separators instead of the default CSV comma separator.

.NET Excel to CSV


How to convert Excel to CSV in C#

Here is an example of how to save an Excel document as a CSV using C#.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;

    using (FileStream inputStream = new FileStream("sample.xlsx",FileMode.Open, FileAccess.Read))
    {
        IWorkbook workbook = application.Workbooks.Open(inputStream);

        using (FileStream outputStream = new FileStream("Output.csv", FileMode.Create, FileAccess.ReadWrite))
        {
            //Save the workbook in CSV format with comma(,) as delimiter
            workbook.SaveAs(outputStream, ",");
        }
    }
}

How to convert Excel to TSV in C#

By changing the separator as tab (“\t”) when saving the workbook, TSV files can be created.

Here is an example of how to convert Excel to TSV in C#.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;

    using (FileStream inputStream = new FileStream("sample.xlsx",FileMode.Open, FileAccess.Read))
    {
        IWorkbook workbook = application.Workbooks.Open(inputStream);

        using (FileStream outputStream = new FileStream("Output.tsv", FileMode.Create, FileAccess.ReadWrite))
        {
            //Save the workbook in CSV format with tab(\t) as delimiter
            workbook.SaveAs(outputStream, "\t");
        }
    }
}

How to convert an Excel file to a text file in C#

By changing the separator to space(“ ”) when saving the workbook, text(.txt) files can be created.

Here is an example of how to convert an Excel file to text files in C#.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;

    using (FileStream inputStream = new FileStream("sample.xlsx",FileMode.Open, FileAccess.Read))
    {
        IWorkbook workbook = application.Workbooks.Open(inputStream);

        using (FileStream outputStream = new FileStream("Output.txt", FileMode.Create, FileAccess.ReadWrite))
        {
            //Save the workbook in .txt format
            workbook.SaveAs(outputStream, " ");
        }
    }
}

Use cases

Besides this Excel to CSV conversion using Syncfusion .NET Excel library, developers can also use:



Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.

Scroll up icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon