/**
* @return the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
*/
- public long getNumerOfMappedColumns() {
+ public long getNumberOfMappedColumns() {
return ctTable.getTableColumns().getCount();
}
+
+ /**
+ * @return the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
+ * @deprecated 3.15 beta 2. Use {@link #getNumberOfMappedColumns}.
+ */
+ public long getNumerOfMappedColumns() {
+ return getNumberOfMappedColumns();
+ }
+
/**
* @return The reference for the cell in the top-left part of the table
* (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
*
+ * Does not track updates to underlying changes to CTTable
*/
public CellReference getStartCellReference() {
if (startCellReference==null) {
* @return The reference for the cell in the bottom-right part of the table
* (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
*
+ * Does not track updates to underlying changes to CTTable
*/
public CellReference getEndCellReference() {
if (endCellReference==null) {
/**
* @return the total number of rows in the selection. (Note: in this version autofiltering is ignored)
*
+ * Does not track updates to underlying changes to CTTable
*/
public int getRowCount() {
CellReference from = getStartCellReference();
package org.apache.poi.xssf.usermodel;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
wb.close();
}
+ @Test
+ public void getSheetName() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals("Table", table.getSheetName());
+ wb.close();
+ }
+
+ @Test
+ public void isHasTotalsRow() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertFalse(table.isHasTotalsRow());
+ wb.close();
+ }
+
+ @Test
+ public void getStartColIndex() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(0, table.getStartColIndex());
+ wb.close();
+ }
+
+ @Test
+ public void getEndColIndex() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(2, table.getEndColIndex());
+ wb.close();
+ }
+
+ @Test
+ public void getStartRowIndex() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(0, table.getStartRowIndex());
+ wb.close();
+ }
+
+ @Test
+ public void getEndRowIndex() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(6, table.getEndRowIndex());
+ wb.close();
+ }
+
+ @Test
+ public void getStartCellReference() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(new CellReference("A1"), table.getStartCellReference());
+ wb.close();
+ }
+
+ @Test
+ public void getEndCellReference() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(new CellReference("C7"), table.getEndCellReference());
+ wb.close();
+ }
+
+ @Test
+ public void getNumberOfMappedColumns() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals(3, table.getNumberOfMappedColumns());
+ wb.close();
+ }
+
+ @Test
+ public void getAndSetDisplayName() throws IOException {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+ XSSFTable table = wb.getTable("\\_Prime.1");
+ assertEquals("\\_Prime.1", table.getDisplayName());
+
+ table.setDisplayName(null);
+ assertNull(table.getDisplayName());
+ assertEquals("\\_Prime.1", table.getName()); // name and display name are different
+
+ table.setDisplayName("Display name");
+ assertEquals("Display name", table.getDisplayName());
+ assertEquals("\\_Prime.1", table.getName()); // name and display name are different
+
+ wb.close();
+ }
}