protected boolean skipName(Name definedName) { String namename = definedName.getNameName(); if (namename == null) { return true; } // ignore defined name of functions, they are macro functions that we don't support if (definedName.isFunctionName()) { return true; } if (definedName.getRefersToFormula() == null) { // ignore defined name with null formula, don't know when will have this case return true; } return false; }
/** * Name should be created after sheets created. A special defined name, _xlnm._FilterDatabase * (xlsx) or _FilterDatabase (xls), stores the selected cells for auto-filter */ protected void importNamedRange() { for (int i = 0; i < workbook.getNumberOfNames(); i++) { Name definedName = workbook.getNameAt(i); if (skipName(definedName)) { continue; } SName namedRange = null; if (definedName.getSheetIndex() == -1) { // workbook scope namedRange = book.createName(definedName.getNameName()); } else { namedRange = book.createName(definedName.getNameName(), definedName.getSheetName()); } namedRange.setRefersToFormula(definedName.getRefersToFormula()); } }