Example usage for org.apache.poi.xssf.usermodel XSSFTable getName

List of usage examples for org.apache.poi.xssf.usermodel XSSFTable getName

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFTable getName.

Prototype

public String getName() 

Source Link

Usage

From source file:com.miraisolutions.xlconnect.Workbook.java

License:Open Source License

public int[] getReferenceCoordinatesForTable(int sheetIndex, String tableName) {
    if (!isXSSF()) {
        throw new IllegalArgumentException("Tables are not supported with this file format");
    }/* w w  w . ja v  a 2  s  .  com*/
    XSSFSheet s = (XSSFSheet) getSheet(sheetIndex);
    for (XSSFTable t : s.getTables()) {
        if (tableName.equals(t.getName())) {
            CellReference start = t.getStartCellReference();
            CellReference end = t.getEndCellReference();
            int top = start.getRow();
            int bottom = end.getRow();
            int left = start.getCol();
            int right = end.getCol();
            return new int[] { top, left, bottom, right };
        }
    }
    throw new IllegalArgumentException("Could not find table '" + tableName + "'!");
}