@@ -, +, @@ /** * Changes the display name of the Table. *

* If {@code name} is null, or is empty, or conflicts with the name of an existing XSSFTable * or XSSFName, then an IllegalARgumentException is thrown. * @param name to use */ public void setDisplayName(String name) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Display name must not be null or empty"); } final XSSFWorkbook workbook=getXSSFSheet().getWorkbook(); if(isInvalidTableName(workbook,name)) { throw new IllegalArgumentException("setDisplayName("+name+"): name conflicts with XSSFName or XSSFTable"); } ctTable.setDisplayName(name); } /** * This method returns true if {@code displayName} conflicts with the name of any {@code XSSFName} or {@code XSSFTable} * in {@code workbook}. * * @param workbook * @param displayName * @return */ static boolean isInvalidTableName(XSSFWorkbook workbook,String displayName) { if(workbook==null) throw new IllegalStateException("isInvalidTableName: getWorkbook returns null"); final Collection names = workbook.getNames(displayName); if (names != null && names.size() > 0) { // name conflicts with an existing XSSFName return true; } for (int n = workbook.getNumberOfSheets() - 1; n >= 0; --n) { final XSSFSheet sheet = workbook.getSheetAt(n); for (XSSFTable table : sheet.getTables()) { if (displayName.equalsIgnoreCase(table.getDisplayName())) { // name conflicts with a table return true; } } } return false; }