Convert XLS XLSX to CSV in Java

XLS or XLSX files are commonly used to store the data in the form of rows and columns. However, while processing the data, you often need to convert Excel files to CSV (Comma Separated Values) format. To perform this conversion programmatically, this article shows how to convert an Excel XLS or XLSX file to CSV in Java.

Java API for XLS to CSV Conversion

To convert Excel XLS or XLSX files to CSV format, we will use Aspose.Cells for Java. It is an amazing API that provides a bunch of features for creating and processing spreadsheet documents. Furthermore, it offers a high-fidelity conversion of spreadsheet files to other formats. You can download its JAR or install it directly using the following Maven configurations.

Repository:

<repository>
	<id>AsposeJavaAPI</id>
	<name>Aspose Java API</name>
	<url>https://repository.aspose.com/repo/</url>
</repository>

Dependency:

<dependency>
	<groupId>com.aspose</groupId>
	<artifactId>aspose-cells</artifactId>
	<version>22.6</version>
</dependency>

Convert an XLS File to CSV in Java

To convert an Excel file to CSV, you only need to load the XLS or XLSX file and save it in CSV format. The following are the steps to convert an XLS file to CSV in Java.

The following code sample shows how to save an XSL file as CSV in Java.

import com.aspose.cells.Workbook;
// Load XLS file
Workbook workbook = new Workbook("input.xls");
// Save XLS as CSV
workbook.save("Output.csv");

Get a Free License

You can get a free temporary license to use Aspose.Cells for Java without evaluation limitations.

Conclusion

In this article, you have learned how to convert XLS or XLSX files to CSV programmatically in Java. The code sample has demonstrated how you can integrate XLS or XLSX to CSV conversion in your Java applications. In addition, you can visit the documentation to explore other features of Aspose.Cells for Java. Also, you can share your questions or queries with us via our forum.

See Also