On 4/26/2010 3:54 AM, Nick Burch wrote:
FWIW, I've not yet had a case of needing the full jar since we've had
the small one, so it isn't very common a need
Nick
Hi Nick,
Have you tried to edit an XSSF spreadsheet? That is what triggered the
problem.
See the simplest case below. It crashes at the end, creating an empty file.
Thx,
-Ramon
----------------------
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* This example demonstrates opening a workbook, modifying
* it and writing the results back out.
* @author Glen Stampoultzis (glens at apache.org)
*/
public class ReadWriteWorkbook {
public static void main(String[] args) throws IOException {
FileInputStream fileIn = null;
FileOutputStream fileOut = null;
XSSFWorkbook wb;
try {
fileIn = new FileInputStream("1-Tab.xlsx");
wb = new XSSFWorkbook(fileIn);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
if (row == null)
row = sheet.createRow(2);
Cell cell = row.getCell(3);
if (cell == null)
cell = row.createCell(3);
cell.setCellType(XSSFCell.CELL_TYPE_STRING);
cell.setCellValue("a test");
// Write the output to a file
fileOut = new FileOutputStream("workbookout.xlsx");
wb.write(fileOut); // Crashes here, creating an empty file
} finally {
if (fileOut != null)
fileOut.close();
if (fileIn != null)
fileIn.close();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]