使用Apache POI列出Excel中所有已定义的名称

时间:2019-05-06 17:07:07

标签: java excel apache-poi

如何使用Apache POI获取excel中所有已定义名称/范围名称的列表?

编辑:感谢@Axel Richter,下面是代码

        List definedNames = new ArrayList();
    definedNames = workbook.getAllNames();
    Iterator<List> definedNameIterator = definedNames.iterator();
    while (definedNameIterator.hasNext()) {
        Name name = (Name) definedNameIterator.next();
        System.out.println(name.getNameName());
        System.out.println(name.getRefersToFormula());
        System.out.println();
    }

1 个答案:

答案 0 :(得分:0)

        List definedNames = new ArrayList();
definedNames = workbook.getAllNames();
Iterator<List> definedNameIterator = definedNames.iterator();
while (definedNameIterator.hasNext()) {
    Name name = (Name) definedNameIterator.next();
    System.out.println(name.getNameName());
    System.out.println(name.getRefersToFormula());
    System.out.println();
}