DEV Community

AsposeCells
AsposeCells

Posted on

Convert Microsoft Excel XLS to XLSX in Java

XLS is an old but widely used Microsoft Excel format. It is a binary file format and known as Binary Interchange File Format (BIFF). Microsoft Excel still supports XLS format for backward compatibility but since it is an old format, many new features are not supported inside it. For that reason, XLS format is often converted to XLSX format which is a newer Open Office XML-based format and supports all new features of Microsoft Excel.

You can convert XLS to XLSX manually using Microsoft Excel 2007 or later versions e.g. Microsoft Excel 2016 etc. or programmatically using Aspose.Cells for Java API with few lines of code. In order to perform its operations, Aspose.Cells does not depend on Microsoft Excel or on any sort of Microsoft Office Automation, VBA (Visual Basic for Applications), VSTO (Visual Studio Tools for Office) etc.

Article Description

The purpose of this article is to explain how developers can convert Microsoft Excel XLS to XLSX format in Java.

Supported Platforms

Aspose.Cells API supports various platforms including Java, .NET, C++, Android, JavaScript, PHP etc. Besides, Aspose.Cells is available in Cloud as REST or RESTful APIs.

Maximum Number of Columns and Rows in XLS and XLSX

XLS format supports

  • 65,536 Rows.
  • 256 Columns.

XLSX format supports

  • 1,048,576 Rows.
  • 16,384 Columns.

Sample Input Microsoft Excel XLS Document

You can convert any XLS document to XLSX using Aspose.Cells API. For illustration, we will use the following sample input Microsoft Excel XLS document that contains textual and numerical formatted data about some companies. Whenever, you will open XLS document in Microsoft Excel, it will show Compatibility Mode as indicated by Red Arrow in the following snapshot.

Sample Microsoft Excel XLS document to be converted to XLSX format using Aspose.Cells API.

Sample Code

The following sample code converts XLS to XLSX by performing these steps.

  • Load the input Microsoft Excel XLS document in com.aspose.cells.Workbook object.
  • Save the com.aspose.cells.Workbook object in XLSX format.

Output Microsoft Excel XLSX by Aspose.Cells

The following snapshot shows the Converted or Output Microsoft Excel XLSX file by Aspose.Cells with the code given above. As you can see, the output XLSX file is exactly similar to XLS file. Similarly, you can convert any XLS file to XLSX with Aspose.Cells API easily.

Output - Convert XLS to XLSX using Aspose.Cells API.

Top comments (2)

Collapse
 
dariusx profile image
Darius

The Apache POI library supports both formats. So, in a Java ecosystem, and with a simple spreadsheet, that's an option. (Complex references an formula would make it "not simple")

Collapse
 
asposecells profile image
AsposeCells

@dariusx

Thanks for your comment and sharing the info.