Convert Excel to CSV and CSV to Excel using C++

Convert Excel to CSV and CSV to Excel using C++

Excel is a popular format for sharing information. You may find yourself in situations where you have data in an Excel(XLS/XLSX) file that you need to import to a database. For this, you would need to convert the Excel file to CSV format. On the other hand, you may have data in CSV format exported from a database that you need to manipulate further in an Excel file. For such cases, you would need to convert the CSV file to Excel format. In this article, you will learn how to perform both these conversions programmatically using C++.

C++ API to Convert Excel Files to CSV and CSV files to Excel Format

Aspose.Cells for C++ is a native C++ library that allows you to create, read and modify Excel files. Furthermore, the API supports converting Excel files to CSV format and vice-versa. You can either install the API through NuGet or download it directly from the Downloads section.

PM> Install-Package Aspose.Cells.Cpp

Converting Excel files to CSV format using C++

Converting Excel files to CSV format is a breeze with Aspose.Cells for C++ API. The following are the steps to convert Excel files to CSV format using C++.

The following is the sample code to convert Excel files to CSV format.

Convert Excel Worksheets to CSV files

The previous example converts only the first worksheet if the Excel file contains multiple worksheets. In case you want to convert multiple worksheets to CSV format, you can follow the following steps.

The following is the sample code to convert Excel worksheets to CSV files using C++.

Converting CSV files to Excel format using C++

The following are the steps to convert CSV files to Excel format using C++.

The following is the sample code to convert CSV files to Excel format using C++.

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have learned how to convert Excel files to CSV format and CSV files to Excel (XLS/XLSX) format using C++. Aspose.Cells for C++ is a vast API that provides many additional features for working with Excel files. You can explore the API in detail by using the official documentation. In case of any questions, please feel free to reach us on our free support forum.

See Also