You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Christian Gosch <ch...@inovex.de> on 2008/08/29 19:08:16 UTC
RE: Problem with POI-3.1-final-20080629, HSSF: HSSFRow.createCell((short)0) throws IllegalStateException
Hi,
attached you find a JUnit test class (source) for the problem.
Package of the test class:
- (default)
Required:
- JUnit (as present in Eclipse 3.4 EE Ganymede),
- POI 3.1 FINAL 20080629
Testing environment was Eclipse 3.4 Ganymede EE and IBM WebSphere
Application Server 6.0.2.19 (with IBM JRE 1.4.2 on WinXP-Pro SP3, which
was set up as the project's JRE).
2 things added:
(1) OK, there is some more code than I provided at first glance, but it
is only formatting stuff, as you will see by inspecting the test case.
(2) I have a "variant" of the code I provide here -- and this variant
works without any problems. If you feel you need this for comparisons, I
can build a second test case based on this "code variant". Of course
there must be a difference, and that difference must be important.
Thanks for investigation,
--
Dipl.-Inform. Christian Gosch
Systems Development
inovex GmbH
Karlsruher Strasse 71
D-75179 Pforzheim
Tel: 07231 3191-85
Fax: 07231 3191-91
c.gosch@inovex.de
www.inovex.de
Sitz der Gesellschaft: Pforzheim
AG Mannheim, HRB 502126
Geschäftsführer: Stephan Müller
> -----Original Message-----
> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Thursday, August 28, 2008 1:28 PM
> To: POI Users List
> Subject: Re: Problem with POI-3.1-final-20080629, HSSF:
> HSSFRow.createCell((short)0) throws IllegalStateException
>
> On Wed, 27 Aug 2008, Christian Gosch wrote:
> > Problem with 3.1 final (20080629): When I start to generate and fill
a
> > new workbook from scratch, I receive:
> >
> > java.lang.IllegalStateException: Cannot create value records before
row
> > records exist
>
> You shouldn't get that on an empty workbook. Any chance you could
write a
> small unit test that triggers the problem, then upload it to bugzilla?
I
> can execute your code snippet just fine, so I can't figure out what's
> wrong for you
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
> !DSPAM:48b68bb822931511210146!
>
>
RE: Problem with POI-3.1-final-20080629, HSSF: HSSFRow.createCell((short)0) throws IllegalStateException
Posted by Christian Gosch <ch...@inovex.de>.
However, here it is:
// ***********************************************
// Copyright (c) 2002-2008, inovex GmbH, Pforzheim, Germany
import junit.framework.TestCase;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFFooter;
import org.apache.poi.hssf.usermodel.HSSFHeader;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
*
* @author inovex GmbH (christian)
* @version $Id: $
* Created 29.08.2008
*/
public class TestPOI31Final extends TestCase {
/**
* @param name
*/
public TestPOI31Final(String name) {
super(name);
}
/**
* setUp
* @see junit.framework.TestCase#setUp()
*
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
super.setUp();
}
/**
* tearDown
* @see junit.framework.TestCase#tearDown()
*
* @throws java.lang.Exception
*/
protected void tearDown() throws Exception {
super.tearDown();
}
/**
* Test method for {@link
org.apache.poi.hssf.usermodel.HSSFRow#createCell(short)}.
*/
public void testCreateCellShort() {
try {
// Testcase for a problem in POI 3.1-FINAL-20080629
HSSFWorkbook workbook = new HSSFWorkbook();;
// create workbook and sheet
HSSFSheet sheet = workbook.createSheet("Vorschauliste");
HSSFRow row = sheet.createRow((short)0);
// apply sheet settings (basic formatting)
sheet.setMargin(HSSFSheet.LeftMargin, 0.3);
sheet.setMargin(HSSFSheet.RightMargin, 0.3);
sheet.setMargin(HSSFSheet.TopMargin, 0.5);
sheet.setMargin(HSSFSheet.BottomMargin, 0.5);
sheet.setAutobreaks( true); // show automatic page breaks or
not
sheet.setDisplayGridlines(true);
sheet.setDisplayRowColHeadings(true);
sheet.setDisplayGuts(true);
sheet.setGridsPrinted(true);
sheet.setPrintGridlines(true); // identisch??
HSSFPrintSetup ps = sheet.getPrintSetup();
ps.setLandscape( true);
ps.setHeaderMargin( 0.3);
ps.setFooterMargin( 0.3);
ps.setPaperSize( HSSFPrintSetup.A4_PAPERSIZE);
sheet.setFitToPage(true);
ps.setFitWidth((short)1);
ps.setFitHeight((short)0);
HSSFFooter footer = sheet.getFooter();
HSSFHeader header = sheet.getHeader();
header.setLeft("");
header.setCenter("a-Xpedite: Testverteiler / teaminterne
Adressen (Personen im Verteiler: 4)");
header.setRight("(Christian Gosch / Inovex GmbH)");
footer.setLeft("29.08.2008 18:17");
footer.setCenter("Vorschauliste");
footer.setRight("Seite &P von &N");
workbook.setRepeatingRowsAndColumns( 0, 0, 0, 0, 0 + 0);
sheet.createFreezePane( 1, 1 + 0);
// proceed in building sheet
// write header (column names)
// Create a new font and alter it.
HSSFFont fontheadline = workbook.createFont();
fontheadline.setFontHeightInPoints((short)10);
fontheadline.setFontName("Arial");
fontheadline.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// create a style for headlines:
HSSFCellStyle boldFormat = workbook.createCellStyle();
boldFormat.setFont(fontheadline);
HSSFCell cell = row.createCell((short)0);
// terminates with exception:
/*
[29.08.08 18:23:21:702 CEST] ERROR [WebContainer : 6]
XLSViewSrv.specialList(): java.lang.IllegalStateException: Cannot create
value records before row records exist
java.lang.IllegalStateException: Cannot create value records before
row records exist
at org.apache.poi.hssf.model.Sheet.checkCells(Sheet.java:497)
at
org.apache.poi.hssf.model.Sheet.addValueRecord(Sheet.java:1041)
at
org.apache.poi.hssf.usermodel.HSSFRow.createCell(HSSFRow.java:134)
at
org.apache.poi.hssf.usermodel.HSSFRow.createCell(HSSFRow.java:115)
at
de.dc.jnet.frame.servlet.XLSViewSrv.specialList(XLSViewSrv.java:1605)
at
de.dc.jnet.frame.servlet.XLSViewSrv.exportFormulaList(XLSViewSrv.java:12
91)
at
de.dc.jnet.frame.servlet.XLSViewSrv.doDispatch(XLSViewSrv.java:525)
at
de.dc.jnet.frame.servlet.XLSViewSrv.doGet(XLSViewSrv.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
[...]
*/
/* Execution environment: IBM WebSphere 6.0.2.19 (IBM JRE 1.4.2),
POI 3.1-FINAL-20080629 */
System.out.println(cell);
System.out.println("OK -- no error here");
} catch (Throwable t) {
fail("ERROR: " + t);
t.printStackTrace();
System.out.println("ERROR: " + t);
}
}
}
// ***********************************************
Not that sophisticated, but it should do.
--
Dipl.-Inform. Christian Gosch
Systems Development
inovex GmbH
Karlsruher Strasse 71
D-75179 Pforzheim
Tel: 07231 3191-85
Fax: 07231 3191-91
c.gosch@inovex.de
www.inovex.de
Sitz der Gesellschaft: Pforzheim
AG Mannheim, HRB 502126
Geschäftsführer: Stephan Müller
> -----Original Message-----
> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Friday, August 29, 2008 7:34 PM
> To: POI Users List
> Subject: RE: Problem with POI-3.1-final-20080629, HSSF:
> HSSFRow.createCell((short)0) throws IllegalStateException
>
> On Fri, 29 Aug 2008, Christian Gosch wrote:
> > attached you find a JUnit test class (source) for the problem.
>
> Alas there was no attachment...
>
> If your mail server is proving useless, it might be easier to open a
new
> bug on bugzilla, and attach your unit test there
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
> !DSPAM:48b8331922931207336982!
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: Problem with POI-3.1-final-20080629, HSSF: HSSFRow.createCell((short)0) throws IllegalStateException
Posted by Christian Gosch <ch...@inovex.de>.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45717
--
Dipl.-Inform. Christian Gosch
Systems Development
inovex GmbH
Karlsruher Strasse 71
D-75179 Pforzheim
Tel: 07231 3191-85
Fax: 07231 3191-91
c.gosch@inovex.de
www.inovex.de
Sitz der Gesellschaft: Pforzheim
AG Mannheim, HRB 502126
Geschäftsführer: Stephan Müller
> -----Original Message-----
> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Friday, August 29, 2008 7:34 PM
> To: POI Users List
> Subject: RE: Problem with POI-3.1-final-20080629, HSSF:
> HSSFRow.createCell((short)0) throws IllegalStateException
>
> On Fri, 29 Aug 2008, Christian Gosch wrote:
> > attached you find a JUnit test class (source) for the problem.
>
> Alas there was no attachment...
>
> If your mail server is proving useless, it might be easier to open a
new
> bug on bugzilla, and attach your unit test there
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
> !DSPAM:48b8331922931207336982!
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: Problem with POI-3.1-final-20080629, HSSF: HSSFRow.createCell((short)0)
throws IllegalStateException
Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 29 Aug 2008, Christian Gosch wrote:
> attached you find a JUnit test class (source) for the problem.
Alas there was no attachment...
If your mail server is proving useless, it might be easier to open a new
bug on bugzilla, and attach your unit test there
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org