2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Yes, XlsIO supports opening and saving of CSV files. Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Also, converts Excel documents to PDF files. Using this library, you can open and save files in CSV file format. By default, CSV files are opened in Excel 2003 format. If the file has more than 65536 rows of data, it is recommended to set the default version to Excel 2007 or above. Steps to open and save files in CSV file format, programmatically:Step 1: Create a new C# console application project. Create a new C# console application Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Install NuGet package Step 3: Include the following namespace in the Program.cs file. C# using Syncfusion.XlsIO;
VB.NET Imports Syncfusion.XlsIO
Step 4: Use the following code snippet to open and save files in CSV file format using XlsIO in C#, VB.NET. C# //Create Excel engine using (ExcelEngine excelEngine = new ExcelEngine()) { //Instantiate the application object IApplication application = excelEngine.Excel; //Set default application verion as Excel 2013 application.DefaultVersion = ExcelVersion.Excel2013; //Open CSV file IWorkbook workbook = application.Workbooks.Open("CSVFile.csv"); //Save CSV file workbook.SaveAs("Output.csv", ","); }
VB.NET 'Create Excel engine Using excelEngine As ExcelEngine = New ExcelEngine() 'Instantiate the application object Dim application As IApplication = excelEngine.Excel 'Set default application verion as Excel 2013 application.DefaultVersion = ExcelVersion.Excel2013 'Open CSV file Dim workbook As IWorkbook = application.Workbooks.Open("CSVFile.csv") 'Save CSV file workbook.SaveAs("Output.csv", ",") End Using
A complete Windows Forms working example of how to open and save CSV file using XlsIO in C# and VB.NET can be downloaded from Open-And-Save-CSV-File.zip. By executing the program, you will get the output as below. Output Excel document Refer here to explore the rich set of Syncfusion Excel (XlsIO) library features. See Also:Convert Excel file to CSV in C#, VB.NET How to convert a CSV file into Excel document using XlsIO in PowerShell? How to export Excel data to CSV file? How to get hyperlink url from the CSV file using XlsIO How to generate CSV file for other languages? Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trial message.
|
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
Thank you. That "," used as second argument in the Open-Command, does that have a different effect than using ExcelOpenType.CSV and wouldn't the latter be cleaner?
Also, when I try to execute it, I get "EXCEPTION: Das angegebene Argument liegt außerhalb des gültigen Wertebereichs." ("Specified argument outside permitted range") Admittedly I am challenging the library because I'm attempting to import a file with 1.000.000 rows, but I think since even Excel can handle that, it shouldn't be a problem for XlsIO ;-)
Hi Michael,
There is no difference between opening a CSV document in XlsIO with comma separator and ExcelOpenType as CSV. We suspect that the exception might be raised due to opening the CSV document with 10,00,000 rows in XlsIO when application version earlier to MS Excel 2007. We request you to set the IApplication.DefaultVersion as Excel.2007 or above before open a file to overcome the issue. Please refer the following code example to achieve this.
Code snippet:
Application.DefaultVersion = ExcelVersion.Excel2007;
Regards,
Sridhar.
Thank you for your suggestion. Did that - and then I get a message "PPPPPP is not valid named range". I'm pretty sure the 1,000,000 rows are the problem - a smaller version of that file with just 50,000 rows went in just fine.
Oh, and just looking at ExcelOPenType, I was wondering why the .CSV is required if there also is a .Automatic - but that did not recognize the file as CSV. (I was hoping I might be able to avoid special casing .CSV with "Automatic", but if that doesn't work, I'll have to do ugly IF's ;-))
Hi Michael,
A support incident to track the status of this query has been created under your account. Please log on to our support website to check for further updates
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
Please let me know if you have any questions.
Regards,
Sridhar.
Hi
I would just like to find out what the resolution to this problem was?
Regards
Hi Adriaan,
We had confirmed this as an issue and it was already fixed in our release v15.3.0.33 which was rolled out in end of September 2017. So, we request you to upgrade to our latest product version v16.2.0.46 to get this issue resolved.
Regards,
Mohan.