SXC to Excel

Convert SXC to Excel using Java

SXC has been a default format of files created in Calc software of the StarOffice suite. The SXC files provided the compatibility with other office suites i.e. Apache OpenOffice, LibreOffice, IBM Lotus Symphony, NeoOffice etc. Athwart, we extensively use Excel worksheets instead of open office excel or open office spreadsheets, but in order to manage, analyze and present the data from legacy SXC files, we need convert SXC files to more adoptive format. Let’s explore the details on how to convert SXC file to Excel worksheet using Java REST API.

SXC to Excel Conversion API

Our Aspose.Cells Cloud SDK for Java is quite popular for excel worksheets creation, manipulation and transformation to variety of other formats within Java application. So with fewer code lines, you get the option to load and transform popular worksheet formats and convert to other desired format. Now in order to get started with its usage, please add the following details in pom.xml of maven build type project.

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cells-cloud</artifactId>
        <version>22.8</version>
    </dependency>
</dependencies>

Once the SDK reference has been added, we need to create a free account over Aspose Cloud. Login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required in subsequent sections.

Export SXC to Excel - Local Storage

In this section, we are going to discuss the details on how to convert Excel to JSON without first uploading the input Excel to cloud storage. However, the resultant JSON file will be stored in cloud storage.

  • Firstly, create a CellsApi object while providing ClientID and Client secret details as arguments
  • Secondly, create a File instance to load source SXC file
  • Then call the cellsWorkbookPutConvertWorkbook(…) method requiring input SXC file name, resultant format as XLS and the name of output file. After successful conversion, the XLS file will be stored in cloud storage

Open Office Excel to XLS using Java

We also have an opportunity to load the Open office Excel (SXC) from Cloud storage and perform the conversion to Excel (XLS, XLSX etc.). So either can load any existing file or upload it first and reference it during the conversion operation. With this approach, the resultant file is also saved in the cloud storage.

  • Firstly, create a CellsApi object while providing ClientID and Client secret details as arguments
  • Secondly, create a File instance to load input SXC workbook
  • Now call the uploadFile(…) method to upload the SXC file to cloud storage
  • Finally, call the cellsWorkbookGetWorkbook(…) method which requires the name of input SXC file, resultant format as XLS as well as its name. After the conversion, the output is saved in cloud storage.
SXC to Excel preview

Image1:- SXC to Excel Conversion Preview

For your reference, the source SXC and the resultant XLS have been shared over source.sxc and output.xls

Export Open Office Spreadsheets to Excel using cURL Commands

Since REST APIs can easily be accessed via cURL commands, so in this section, we are going to call Aspose.Cells Cloud via cURL commands to accomplish our requirement. Now one of the pre-requisite for this operation is to generate a JWT access token (based on client credentials) while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now once we have the JWT token, we need to execute the following command to convert open office spreadsheets to XLS. The resultant XLS will be stored in cloud storage.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/source.sxc?format=XLS&isAutoFit=false&onlySaveTable=false&outPath=output.xls&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Conclusion

This article has explained the conversion of Open Office Spreadsheets (SXC) to XLS, XLSX etc format using Java code snippet. Similarly, we have also explored an option of converting SXC to Excel using the cURL commands while executing them over command line terminal. You may notice another good aspect of converting Open Office Excel (SXC) to XLS is that the size of this new file is reduced/optimized. Please note that all our Cloud SDKs are built under MIT license, so the complete source code can be downloaded from GitHub. You may consider approaching us for a quick resolution of issues via free product support forum.

We highly recommend visiting the following links to learn more about: