poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52233] New: IndexOutOfBoundsException when calling sheet.getColumnWidth after calling XSSFWorkbook.write
Date Wed, 23 Nov 2011 16:22:31 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52233

             Bug #: 52233
           Summary: IndexOutOfBoundsException when calling
                    sheet.getColumnWidth after calling XSSFWorkbook.write
           Product: POI
           Version: 3.8-dev
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: sowen@cs.manchester.ac.uk
    Classification: Unclassified


Whenever I write a XSSFWorkbook out using XSSFWorkbook.write, the book
afterwards is left in a state where calling getColumnWidth on one of its sheet
causes an IndexOutOfBoundsException. Below is a unit test that isolates the
problem (in this case it creates a new Workbook and constucts a sheet and
cells, but I also have the same problem when starting from an existing workbook
loaded through WorkbookFactory).

@Test
public void testColumnWidthPOI() throws Exception {
       XSSFWorkbook workbook = new XSSFWorkbook();
       XSSFSheet sheet = workbook.createSheet();
       XSSFRow row = sheet.createRow(0);
       XSSFCell cell = row.createCell(0);
       cell.setCellValue("hello world");
       assertEquals("hello
world",workbook.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
       assertEquals(2048,workbook.getSheetAt(0).getColumnWidth(0)); //<-works

       //gets a UUID based temporary file
       File tmpDir = new File(System.getProperty("java.io.tmpdir"));
       String uuid = UUID.randomUUID().toString();
       File f = new File(tmpDir,uuid+".xlsx");

       BufferedOutputStream stream = new BufferedOutputStream(new
FileOutputStream(f));
       workbook.write(stream);
       stream.close();
       assertTrue(f.exists());

       assertEquals("hello
world",workbook.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
       assertEquals(2048,workbook.getSheetAt(0).getColumnWidth(0)); //<- throws
IndexOutOfBoundsException
   }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


Mime
View raw message