Hi,

The below code produces two workbooks that are identical except for whether
they used SXSSFWorkbook and the other with an XSSFWorkbook.   Both open fine
on Windows, but on the mac, the strings do not show up in the sheet that was
created with SXSSFWorkbook.  Numeric cells show fine, but strings don’t. 
This is true in Preview on the MacBook, and on the iPad any of the free apps
I could find to open .xlsx (FileApp, FileLite, Documents 2).

The only difference in the files appears to be that in the SXSSFWorkbook the
string contents are inline as inlineStr cells, while in XSSFWorkbook they’re
in sharedStrings.xml and apparently the native mac .xlsx viewer can’t handle
inline strings.

*My question is this*: can SXSSFWorkbook  be altered to use
sharedStrings.xml instead of inlineStr cells?    (On the assumption that
that's what's breaking preview on the mac.)

Background info/motivation:
* We want to use SXSSFWorkbook because we’re producing workbooks from our
own reports which can be too large to hold in memory.  If we can’t get this
working we’ll use the XSSFWorkbook and some fancy footwork to bail out if
we’re about to run out of memory.  But we’d much prefer the robustness of
SXSSFWorkbook.
* iPad and iPhone support is one of our key features and we can’t require
all our customers to install Excel or other readers on their apple devices
* Other aspects of the mac Preview are problematic (doesn’t handle Boolean
or error cells) but for our purposes only the number and string cells are of
interest 
* This was tested on iPad3 with iOS 5, and on MacBook Pro with OS X Mountain
Lion.  


Thanks for any guidance.  

class TestExcelExport {
   
    public static void main(String[] args) throws Exception {
        streamedExcelx();
        unstreamedExcelx();
    }

    public static void streamedExcelx() throws IOException,
FileNotFoundException {
        SXSSFWorkbook book = new SXSSFWorkbook();        
        addCells(book);        
        FileOutputStream fileOut = new
FileOutputStream("SXSSFWorkbook.xlsx");
        book.write(fileOut);
        fileOut.flush();
        fileOut.close();
    }

    public static void unstreamedExcelx() throws IOException,
FileNotFoundException {
        XSSFWorkbook book = new XSSFWorkbook();         
        addCells(book);       
        FileOutputStream fileOut = new
FileOutputStream("XSSFWorkbook.xlsx");
        book.write(fileOut);
        fileOut.flush();
        fileOut.close();
    }

    public static void addCells(Workbook book) {
        Sheet sheet = book.createSheet();
        Row row = sheet.createRow(0);
        int columnNumber = 0;
        
        row.createCell(columnNumber++); // blank cell
    
        Cell numberCell = row.createCell(columnNumber++);
        numberCell.setCellType(Cell.CELL_TYPE_NUMERIC);
        numberCell.setCellValue(1.0);

        Cell stringCell = row.createCell(columnNumber++);
        stringCell.setCellType(Cell.CELL_TYPE_STRING);
        stringCell.setCellValue("string");
    }
} 



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/SXSSFWorkbook-can-t-be-viewed-correctly-on-the-mac-tp5713570.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to