You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by re...@gmx.de on 2006/03/15 09:22:25 UTC
HSSFSerializer without using Cocoon
Hello,
i want to use in my J2SE-Application the HSSFSerializer without the Cocoon
Framework. The goal is, to generate xls-Files over xml-Files (Gnumeric File
Format).
For this problem i have written a class (XlsTransformer). But i get a NPE
during parsing the xmlFile.
Questions:
1. Can anyone give me a tip for solving my NPE-Problem?
2. Have anyone a Snippet of using HSSFSerializer stand-alone?
3. Have anyone heared from the Apache Sandbox project Morphos?
3a. Have you the Morphos SourceCode? (I surpose that there is a sample
of using HSSFSerializer)
Thank you for your help!
Ralf
Here comes the Code and StackTrace:
For this Project i use divers Libs:
- avalon-framework-api
- poi
- excalibur
- cocoon with HSSFSerializer
Here is the JavaCode from the Class that uses the HSSFSerializer:
public class XlsTransformer
{
public XlsTransformer(String xmlFile)
{
HSSFSerializer hssf = new HSSFSerializer();
XMLReader reader = null;
try
{
reader = XMLReaderFactory.createXMLReader();
}
catch (SAXException e) {
System.err.println("ERROR: No XMLReader!");
e.printStackTrace();
}
try
{
hssf.initialize();
}
catch (Exception e1)
{
e1.printStackTrace();
}
reader.setContentHandler(hssf);
try
{
InputSource inputSource = new InputSource
(new FileInputStream(xmlFile));
reader.parse(inputSource);
}
catch (IOException e) {
System.err.println("ERROR: Parseerror - IOException");
e.printStackTrace();
}
catch (SAXException e) {
System.err.println("ERROR: Parseerror - SAXException");
e.printStackTrace();
}
try
{
hssf.setOutputStream(new FileOutputStream("result.xls"));
}
catch (FileNotFoundException e)
{
System.err.println("ERROR - Can not create Excel-File!");
e.printStackTrace();
}
}
}
StackTrace:
Exception in thread "main" java.lang.NullPointerException
at
org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyleRegion.initialize(EPStyleRegion.java:92)
at
org.apache.cocoon.serialization.ElementProcessorSerializer.startElement(ElementProcessorSerializer.java:414)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
Source)
at xml.xls.XlsTransformer.<init>(XlsTransformer.java:69)
at xml.xls.XmlXslMorpher.main(XmlXslMorpher.java:33)
--
"Feel free" mit GMX FreeMail!
Monat f�r Monat 10 FreeSMS inklusive! http://www.gmx.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
HSSFSerializer without using Cocoon
Posted by re...@gmx.de.
Hello,
i want to use in my J2SE-Application the HSSFSerializer without the Cocoon
Framework. The goal is, to generate xls-Files over xml-Files (Gnumeric File
Format).
For this problem i have written a class (XlsTransformer). But i get a NPE
during parsing the xmlFile.
Questions:
1. Can anyone give me a tip for solving my NPE-Problem?
2. Have anyone a Snippet of using HSSFSerializer stand-alone?
3. Have anyone heared from the Apache Sandbox project Morphos?
3a. Have you the Morphos SourceCode? (I surpose that there is a sample
of using HSSFSerializer)
Thank you for your help!
Ralf
Here comes the Code and StackTrace:
For this Project i use divers Libs:
- avalon-framework-api
- poi
- excalibur
- cocoon with HSSFSerializer
Here is the JavaCode from the Class that uses the HSSFSerializer:
public class XlsTransformer
{
public XlsTransformer(String xmlFile)
{
HSSFSerializer hssf = new HSSFSerializer();
XMLReader reader = null;
try
{
reader = XMLReaderFactory.createXMLReader();
}
catch (SAXException e) {
System.err.println("ERROR: No XMLReader!");
e.printStackTrace();
}
try
{
hssf.initialize();
}
catch (Exception e1)
{
e1.printStackTrace();
}
reader.setContentHandler(hssf);
try
{
InputSource inputSource = new InputSource
(new FileInputStream(xmlFile));
reader.parse(inputSource);
}
catch (IOException e) {
System.err.println("ERROR: Parseerror - IOException");
e.printStackTrace();
}
catch (SAXException e) {
System.err.println("ERROR: Parseerror - SAXException");
e.printStackTrace();
}
try
{
hssf.setOutputStream(new FileOutputStream("result.xls"));
}
catch (FileNotFoundException e)
{
System.err.println("ERROR - Can not create Excel-File!");
e.printStackTrace();
}
}
}
StackTrace:
Exception in thread "main"
java.lang.NullPointerException
at
org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyleRegion.initialize(EPStyleRegion.java:92)
at
org.apache.cocoon.serialization.ElementProcessorSerializer.startElement(ElementProcessorSerializer.java:414)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
Source)
at xml.xls.XlsTransformer.<init>(XlsTransformer.java:69)
at xml.xls.XmlXslMorpher.main(XmlXslMorpher.java:33)
--
"Feel free" mit GMX FreeMail!
Monat für Monat 10 FreeSMS inklusive! http://www.gmx.net
--
Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org