You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Belkauskas Ramúnas <be...@oksystem.cz> on 2011/07/14 13:11:32 UTC

RE: Last column not recognized from Excel with even no of columns

Try to create your columns in reverse order. It should be enough only for the first Row of your Sheet to create Cells from the highest index down to zero.
This doesn't work for 2 columns though.

  R.

Upozornění společnosti OKsystem s.r.o. s ohledem na zavedené standardy ISO 9001, ISO 27001 a ISO 14001:
Tato zpráva a všechny připojené soubory jsou dle obchodního zákoníku důvěrné. Jestliže nejste zamýšleným adresátem, uvědomte prosím odesilatele a smažte zprávu i přiložené soubory.
Opravdu potřebujete vytisknout tento email? Myslete na přírodu.

Disclaimer of OKsystem s.r.o. with respect to implemented standards ISO 9001, ISO 27001 and ISO 14001:
This message and all attached files are confidential and legally privileged. If you are not the intended recipient, please notify the sender and delete the message including all attachments.
Please consider the environment before printing this email.

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


Re: Last column not recognized from Excel with even no of columns

Posted by Christian Brenninkmeijer <Br...@cs.man.ac.uk>.
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);
         hssfWorkbook.write(outputStream);
         outputStream.close();
         /* 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);
         System.out.println(jxlCell.getContents());
         jxlSheet = jxlWorkbook.getSheet("bar");
         jxlCell = jxlSheet.getCell(2, 1);
         System.out.println(jxlCell.getContents());
     }
}

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


Re: Last column not recognized from Excel with even no of columns

Posted by Yegor Kozlov <ye...@dinom.ru>.
HSSF or XSSF? Can you post sample code to demonstrate the problem ?

Yegor

2011/7/14 Belkauskas Ramúnas <be...@oksystem.cz>:
> Try to create your columns in reverse order. It should be enough only for the first Row of your Sheet to create Cells from the highest index down to zero.
> This doesn't work for 2 columns though.
>
>  R.
>
> Upozornění společnosti OKsystem s.r.o. s ohledem na zavedené standardy ISO 9001, ISO 27001 a ISO 14001:
> Tato zpráva a všechny připojené soubory jsou dle obchodního zákoníku důvěrné. Jestliže nejste zamýšleným adresátem, uvědomte prosím odesilatele a smažte zprávu i přiložené soubory.
> Opravdu potřebujete vytisknout tento email? Myslete na přírodu.
>
> Disclaimer of OKsystem s.r.o. with respect to implemented standards ISO 9001, ISO 27001 and ISO 14001:
> This message and all attached files are confidential and legally privileged. If you are not the intended recipient, please notify the sender and delete the message including all attachments.
> Please consider the environment before printing this email.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

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