0

How do I convert an "XML Spreadsheet" document into Excel using Java code?

I can do this manually by opening this document (which windows recognize that it can be opened in Excel, so it opened it in Excel) in Excel and File->Save As-> Excel 2003 workbook. However, I'd prefer I can automate this. Is there anyway we can do this? I also tried to copy the xml spreadsheet file (ends with .xml) to Excel (ends with .xls), but don't work as Apache POI still treat it as an xml document.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
dale
  • 439
  • 3
  • 11
  • 28
  • *"Have a quick question.."* "What is the meaning of life?" Is a quick question - to ask. Does not mean it has a quick answer. ;) – Andrew Thompson May 06 '13 at 02:30

2 Answers2

0

If you have xml file and you are converting to xls file then u can use sax parse to read data from xml file and then convert that data to xls file. You can easily create xls file by using servlet response.setContent() method.

Jayant Jadhav
  • 318
  • 4
  • 12
  • Thanks mate, got a solution to my original issue, this question was part of attempted solution to my issue – dale May 06 '13 at 06:56
0

Unfortunately, it looks like that Apache POI does not support Excel XML Spreadsheet format.

However, commercial products exists to load Excel XML Spreadsheet, such as EasyXLS, c.f. How to convert XML spreadsheet file to Excel in Java (I didn't tested it personally).

And other path, is to pilot Excel via COM (this requires to have Windows operating system along with an Excel installation), e.g.

  1. using the Java COM Bridge Jacob, this technique is discussed in the following article: Excel XML Spreadsheet in Java
  2. another way would be to start a Process running a Powershell script piloting Excel via COM.
Frédéric
  • 565
  • 1
  • 5
  • 10