2013年10月22日星期二

Pro poi problems when writing excel help look it


brother foundation is weak , seeking guidance
------ Solution ------------------------------ --------------
poi absolutely support the 07 version of excel writing . Landlord writes the code in question .
landlord open output streams and book.write are doing inside the for loop , the right should be put inside the table of contents for loop modifying the write-once , because 07 is actually run excel xml based SAX way the . Can not be rolled back
------ Solution ------------------------------------ --------
really hua Shan , not excel the official website of the examples came out. . ,

    public static void main(String[] args) throws Throwable {
        SXSSFWorkbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
        Sheet sh = wb.createSheet();
        for(int rownum = 0; rownum < 1000; rownum++){
            Row row = sh.createRow(rownum);
            for(int cellnum = 0; cellnum < 10; cellnum++){
                Cell cell = row.createCell(cellnum);
                String address = new CellReference(cell).formatAsString();
                cell.setCellValue(address);
            }

        }

        // Rows with rownum < 900 are flushed and not accessible
        for(int rownum = 0; rownum < 900; rownum++){
          Assert.assertNull(sh.getRow(rownum));
        }

        // ther last 100 rows are still in memory
        for(int rownum = 900; rownum < 1000; rownum++){
            Assert.assertNotNull(sh.getRow(rownum));
        }
        
        FileOutputStream out = new FileOutputStream("/temp/sxssf.xlsx");
        wb.write(out);
        out.close();

        // dispose of temporary files backing this workbook on disk
        wb.dispose();
    }

------ For reference only ----------------------------------- ----
POI does not support xlsx format writes. . That is the 2007 version of that , but the 2007 version supports reading
POI write only support xls extensions . .
------ For reference only -------------------------------------- -


Oh, no you sure you do not scare me , but I look at it pro official website write a read and write it
------ For reference only ---------------------------------------

  
Oh, no you sure you do not scare me , but I look at it pro official website write a read and write it  
I have used before , the official website of the demo does not find examples of writing xlsx , xls to have written .
I'm not quite sure , but I use it every time before did not solve this problem, if you find it tell me
If xlsx support writing , then it should not HSSF format output stream , but other

------ For reference only ---------------------------------- -----


I put into circulation outside writing can be friends , thank you. But another problem is that the data is written there , but not updated , or when reading the original data, manually open excel when prompted to update when clicked will show the written data. In this case, how to do it ,

没有评论:

发表评论