poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Brenninkmeijer <Brenn...@cs.man.ac.uk>
Subject Re: Last column not recognized from Excel with even no of columns
Date Fri, 15 Jul 2011 10:43:34 GMT
There is a bug with how (at least hssf sometimes records workbook sizes.

In the code below I write with HSSF and then open it with jxl.

There is then a warning
Warning:  Some cells exceeded the specified bounds.  Resizing sheet 
dimensions from 1x2 to 2x2

Note: If I Open and the Save the workbook using Excel and then just run 
the jxl part there is no such warning so it is a HSSF issue.

tested with poi.3.7-20101029

=== Example code ====
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class ColumnProblem {

     public static void main(String[] args) throws Exception {
         File file = new File("test.xls");
         /* HSSF PART */
         HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
         HSSFSheet hssfSheet = hssfWorkbook.createSheet("foo");
         HSSFRow hssfRow = hssfSheet.createRow(1);
         HSSFCell hssfCell = hssfRow.createCell(1);
         hssfCell.setCellValue("Hello World");
         hssfSheet = hssfWorkbook.createSheet("bar");
         hssfRow = hssfSheet.createRow(1);
         hssfCell = hssfRow.createCell(2);
         hssfCell.setCellValue("Me again World");
         FileOutputStream outputStream = new FileOutputStream(file);
         /* JXL Part */
         jxl.WorkbookSettings settings = new jxl.WorkbookSettings();
         settings.setEncoding("iso-8859-1"); // TODO encoding cfg 
support - use hard-coded latin1 by now...
         FileInputStream inputStream = new FileInputStream(file);
         jxl.Workbook jxlWorkbook = jxl.Workbook.getWorkbook(inputStream 
, settings);
         jxl.Sheet jxlSheet = jxlWorkbook.getSheet("foo");
         jxl.Cell jxlCell = jxlSheet.getCell(1, 1);
         jxlSheet = jxlWorkbook.getSheet("bar");
         jxlCell = jxlSheet.getCell(2, 1);

On 15/07/2011 11:39, Yegor Kozlov wrote:
> HSSF or XSSF? Can you post sample code to demonstrate the problem ?
> Yegor
Christian Brenninkmeijer
Department of Computer Science
University of Manchester

To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message