ASF Bugzilla – Attachment 36563 Details for
Bug 63401
XSSFTable.getName throws an error if called before calling setName
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
JUnit Test case to illustrate bug 63401
file_63401.txt (text/plain), 3.24 KB, created by
David Gauntt
on 2019-05-04 16:48:08 UTC
(
hide
)
Description:
JUnit Test case to illustrate bug 63401
Filename:
MIME Type:
Creator:
David Gauntt
Created:
2019-05-04 16:48:08 UTC
Size:
3.24 KB
patch
obsolete
>package org.apache.poi.ss.usermodel; > >import static org.junit.Assert.assertEquals; >import static org.junit.Assert.assertTrue; > >import java.awt.Desktop; >import java.io.File; >import java.io.FileOutputStream; >import java.io.IOException; >import java.io.OutputStream; >import java.util.Locale; > >import org.apache.poi.ss.SpreadsheetVersion; >import org.apache.poi.ss.util.AreaReference; >import org.apache.poi.ss.util.CellReference; >import org.apache.poi.xssf.usermodel.XSSFCell; >import org.apache.poi.xssf.usermodel.XSSFName; >import org.apache.poi.xssf.usermodel.XSSFRow; >import org.apache.poi.xssf.usermodel.XSSFSheet; >import org.apache.poi.xssf.usermodel.XSSFTable; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; >import org.junit.After; >import org.junit.Before; >import org.junit.Test; > >/** > * Test case for POI Bugzilla error 63401 > */ >public class TestXSSFTableGetName { > XSSFWorkbook workbook=null; > XSSFSheet sheet0=null; > XSSFTable table=null; > > /** > * This creates a workbook with a single worksheet, and a single > * table in that worksheet > */ > @Before > public void setup() { > workbook = new XSSFWorkbook(); > sheet0 = workbook.createSheet(); > > // Create the two tables > table=addTable(sheet0,3,0,2,2); > > } > > @After > public void cleanup() { > final String procName="TestXSSFTableGetName.cleanup"; > if (workbook == null) { > System.err.println(String.format(Locale.ROOT,"%s: workbook==null",procName)); > return; > } > try { > workbook.close(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > > /** > * Delete table2, and create a named range in sheet0; it should automatically be assigned the name "Table4" > */ > @Test > public void testXSSFTableGetName() { > final String procName="testXSSFTableGetName"; > boolean bSuccess=false; > try { > final String name=table.getName(); > bSuccess=true; > System.out.println(String.format(Locale.ROOT, "%s: table.getName=%s",procName,name)); > } catch(Exception err) { > err.printStackTrace(); > bSuccess=false; > } > > assertTrue(bSuccess); > } > > > > private static XSSFTable addTable(XSSFSheet sheet,int nRow, int nCol, int nNumRows, int nNumCols) { > for (int i = 0; i < nNumRows; i++) { > XSSFRow row = sheet.createRow(i + nRow); > for (int j = 0; j < nNumCols; j++) { > XSSFCell localXSSFCell = row.createCell(j + nCol); > if (i == 0) { > localXSSFCell.setCellValue(String.format("Col%d", j + 1)); > } else { > localXSSFCell.setCellValue(String.format("(%d,%d)", i + 1, j + 1)); > } > } > } > final CellReference upperLeft = new CellReference(nRow, nCol); > final CellReference lowerRight = new CellReference(nNumRows - 1, nNumCols - 1); > final AreaReference area = new AreaReference(upperLeft, lowerRight, SpreadsheetVersion.EXCEL2007); > return sheet.createTable(area); > } > > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 63401
: 36563 |
36564