We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

XML file to Microsoft Excel file conversion (java)

Hi Aspose Team,

Is there any way to convert .xml file to .xlsx file (or other microsoft excel file formats) using the aspose.cells component?


Hi Rama,

Thanks for your posting and using Aspose.Cells.

Aspose.Cells can open and convert the xml file that are related to MS-Excel. These are called SpreadsheetML. Not all types of xml can be opened though.

For example, I have attached one such file for your reference. The following code opens the attached xml file and converts it to xlsx file which is also attached for you to view.


String filePath = “F:\Shak-Data-RW\Downloads\SampleExcel.xml”;

//Load the source workbook

Workbook workbook = new Workbook(filePath);

//Save the workbook

workbook.save(filePath + “.out.xlsx”);

Thank you for your prompt response regarding my question, as well as the sample files you attached. As you mentioned in your post, there are only specific types of xml that can be converted. Does the xml that can be converted have to have follow specific schemas or contain namespaces exactly as the ones below I noticed from your sample files?

<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns=“urn:schemas-microsoft-com:office:spreadsheet”

Also, if I were to feed in a similar xml such as the one I attached along with this post, would the conversion work?


Hi Rama,

Thank you for writing back.

Please note, Aspose.Cells for Java API can read an XML that follows the “XML Spreadsheet” paradigm. Unfortunately, your provided sample file does not follow the specifications therefore the API threw an error of type CellsException: with message “This file’s format is not supported or you don’t specify a correct format.” while loading the said sample.

You can create an XML Spreadsheet with MS Excel application by using the Save As menu, and select “XML Spreadsheet 2003” from the dropdown.

Thank you for the directions to create the xml data. I tried to run the code that Shakeel had written earlier to do the conversion, however I run into the below error. I tried with two different version of the aspose.cells library jars (aspose-cells-8.0.0 and aspose-cells-, which resulted in the same error. I am not sure if I’m missing something else.

java.lang.NoClassDefFoundError: com/ctc/wstx/stax/WstxInputFactory
at com.aspose.cells.b.a.h.k.b(Unknown Source)
at com.aspose.cells.b.a.h.k.a(Unknown Source)
at com.aspose.cells.b.a.h.k.a(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.a.c.z.a(Unknown Source)
at com.aspose.cells.sa.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at xmlToExcelDataConversion.XmlToExcel2.main(XmlToExcel2.java:14)
Caused by: java.lang.ClassNotFoundException: com.ctc.wstx.stax.WstxInputFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 11 more

Hi Rama,

Thank you for writing back.

I suspect that you haven’t added the reference of “bcprov-jdk16-xxx.jar” in the class path of your project. Please note, the said jar is present in the same folder as of “aspose-cells-8.0.0.jar”.

I wasn’t able to find that jar in the same folder as the aspose jar. I currently have the free trial version of aspose-cells-8.0.jar. However I do have another version and its corresponding bcprov-jdk15-xxx.jar file. I tried re-testing after importing that jar, and the same error still appears. Any other imports I may be missing?



Well, the jar file “bcprov-jdkxxxxxx” is there in the folders e.g “JDK 1.5\lib” and “JDK 1.6\lib” with the component main Jar file. I suspect you are still using older version Jars e.g v.7.3.x with all its dependencies (other Jars (5 JARs in total) into your class path. Please remove those JARs into your class path and use only our latest version of the product i.e. Aspose.Cells for Java v8.0.0 which has only two Jars present into JDK1.x folder @ your installation directory. For your information, since the release of Aspose.Cells for Java v7.5.0, we have implemented our own XML parser and remove the dependency of woodstox library and some other jars (your error is due to this JAR file). We recommend you to use our latest version i.e. v8.0.0. You only need to set the jars in the “\JDK 1.5\lib” or “\JDK 1.6\lib” into your class path at your installation directory where you extracted the version v8.0.0.

Let us know if you still find any issue or confusion.

Thank you.