Hi there,
I've a program which should convert an XML file to excel file format.I exported the XML file from MS-Excel XP.I'm getting a ClassCastException when I'm trying to convert the exported xml file to xls.I'm using cocoon-2.0.4 with jdom 1.0. What could be the problem?
The original xls and the exported xml file is attached.Both the xml and xls are opening fine with MS Excel XP
NOTE: The attached XML is exported from MS EXCELL XP and not generated by the code give below.
java.lang.ClassCastException: org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyles
at org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyle.initialize(EPStyle.java:160)
at org.apache.cocoon.serialization.ElementProcessorSerializer.startElement(ElementProcessorSerializer.java:508)
at org.jdom.output.SAXOutputter.startElement(SAXOutputter.java:1025)
at org.jdom.output.SAXOutputter.element(SAXOutputter.java:894)
at org.jdom.output.SAXOutputter.elementContent(SAXOutputter.java:1093)
at org.jdom.output.SAXOutputter.elementContent(SAXOutputter.java:1067)
at org.jdom.output.SAXOutputter.element(SAXOutputter.java:897)
at org.jdom.output.SAXOutputter.elementContent(SAXOutputter.java:1093)
at org.jdom.output.SAXOutputter.elementContent(SAXOutputter.java:1067)
at org.jdom.output.SAXOutputter.element(SAXOutputter.java:897)
at org.jdom.output.SAXOutputter.output(SAXOutputter.java:621)
at XMLExcel.main(XMLExcel.java:43)
public class XMLExcel {
public static void main(String[] args) {
File infile = new
File( "C:/ari.xml" );
File outfile = new
File( "C:/ari.xls" );
try {
outfile.createNewFile();
OutputStream fos = new FileOutputStream( outfile );
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build( infile );
HSSFSerializer hssf = new HSSFSerializer();
hssf.initialize();
hssf.setOutputStream( fos );
SAXOutputter saxOutput = new SAXOutputter( hssf );
saxOutput.output( doc );
System.out.println( "Done" );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
Thanks!!
Regards,
Arijit
ari.xml
Description: Binary data
ari.xls
Description: MS-Excel spreadsheet
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
