> Having said that the Workbook interface is defined in the ss.usermodel
> package. Both the XSSFWorkbook and HSSFWorkbook classes implement it.
Ok, I tried the following with success:
HSSFWorkbook wb = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("C:\\workbook.xls");
wb.write(fileOut);
fileOut.close();
But the following without success (narrowed down to this line I think).
XSSFWorkbook wb = new XSSFWorkbook();
...this error message.
java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
...tried these imports.
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.*;
I don't think it's the path because, as stated above, they both
derive from ss.usermodel.
Anyone have a suggestion?
Thanks,
Jeff.
MSB <markbrdsly <at> tiscali.co.uk> writes:
>
>
> I did not contribute to the guide Jeff so must admit that this is a guess.
> Having said that the Workbook interface is defined in the ss.usermodel
> package. Both the XSSFWorkbook and HSSFWorkbook classes implement it and it
> - the interface - contains a number of common method declarations. The
> reason - at least as far as I am aware - that it was added to the API is to
> allow developers to support both binary and OpenXML based Excel files from a
> common code set.
>
> It may be the case that the application cannot 'know' until runtime exactly
> which file format it is dealing with. So, you declare a variable of the
> interface type in the knowledge that a reference to an instance of either
> the HSSFWorkbook or XSSFWorkbook can be stored into it. The WorkbookFactory
> class is the key to all of this; it can accept an InputStream and work out
> from that stream whether the application is processing an OpenXML or binary
> file, returning an instance of the appropriate class.
>
> Hope that heps.
>
> Mark B
>
> Jeff Spence wrote:
> >
> > Hello,
> >
> > I have a question about line one in example one, entitled "New
> > Workbook"
> > here is line one:
> >
> > // Workbook wb = new HSSFWorkbook();
> >
> > My compiler complained about the declaration "Workbook", and suggested
> > that
> > I change it to HSSFWorkbook, which I did and it worked fine.
> >
> > My questions is about the the statement. I have seen a similar pattern in
> > another example that I was studying. Such as:
> >
> > // protected final List<ItemFile> dataList = new ArrayList<ItemFile>();
> >
> > Where the declaration is farther up the hierarchy and the instantiation
> > lower.
> > I don't understand why one would do this.
> >
> > Can someone please point me in the right direction?
> >
> > Thanks,
> > JSpence.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe <at> poi.apache.org
> > For additional commands, e-mail: user-help <at> poi.apache.org
> >
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]