Adding one more thing:
Here's the specific implementation:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java?revision=1704710&view=markup#l196
public static Workbook create(InputStream inp, String password)
throws IOException, InvalidFormatException, EncryptedDocumentException
{
<SNIP>
// Ensure that there is at least some data there
byte[] header8 = IOUtils.peekFirst8Bytes(inp);
// Try to create
if (NPOIFSFileSystem.hasPOIFSHeader(header8)) {
NPOIFSFileSystem fs = new NPOIFSFileSystem(inp);
return create(fs, password);
}
if (POIXMLDocument.hasOOXMLHeader(inp)) {
return new XSSFWorkbook(OPCPackage.open(inp));
}
throw new InvalidFormatException("Your InputStream was neither
an OLE2 stream, nor an OOXML stream");
}
WorkbookFactory.create is peeking at the first few bytes of the file
to guess what format it is. Note that POI does not support Excel 2007
Binary (XLSB) format.
On Wed, Oct 28, 2015 at 11:46 PM, Rohit Cha <[email protected]> wrote:
> Does WorkbookFactory.create(input) can read both excel-2003 and excel-2007
> with out any exception or do we need to use xssf and hssf seperately for
> each one
>
>
> FileInputStream input = new FileInputStream(
>
> "/Users/Desktop/Spice+tool.xls");
>
>
> Workbook wb = WorkbookFactory.create(input);
>
> Sheet sheet = wb.getSheetAt(0);
>
> System.out.println(String.valueOf(sheet.getRow(11).getCell(0)));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]