Articles in this section
Category / Section

How to generate CSV file for other languages?

1 min read

CSV stands for Comma Separated Values. Files that contain the .csv extension are comma delimited files which are very similar to plain text files.

To generate CSV files for other languages, XlsIO enables an UTF8 encoding option while saving the file. The following code snippets illustrates the behavior to generate a CSV file for the other languages.

C#

            IWorkbook  workbook = application.Workbooks.Create(1);
 
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet worksheet = workbook.Worksheets[0];
            worksheet.Range["A1"].Text = "добро пожаловать , Привет, мир";
workbook.Version = ExcelVersion.Excel2013;
                workbook.Worksheets[0].SaveAs(("output.csv", ",", System.Text.Encoding.UTF8);

VB

            
           Dim workbook As IWorkbook = application.Workbooks.Create(1)
 
            'The first worksheet object in the worksheets collection is accessed.
            Dim worksheet As IWorksheet = workbook.Worksheets(0)
            worksheet.Range("A1").Text = "добро пожаловать , Привет, мир"
            workbook.Version = ExcelVersion.Excel2013
            workbook.Worksheets(0).SaveAs(("output.csv", ",", System.Text.Encoding.UTF8)
 

 

 

CSV file

Figure 1: Output CSV File

 

The sample to generate CSV file for other languages can be downloaded here.

The encoding options are enabled for better performance, which avoids encoding checks internally. Here, we recommend to use the below code snippet to achieve the requirement with other languages.

'Code to convert to other languages
worksheet.SaveAs("CSV_File", ",", System.Text.Encoding.UTF8);

'Code for ASCII values
worksheet.SaveAs("CSV_File", ",", System.Text.Encoding.ASCII);

'Code that performs internal encoding
worksheet.SaveAs("CSV_File", ",");

 



Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied