Apache Poi performance issue with WorkbookFactory.create()

喜你入骨 提交于 2019-12-11 20:04:02

问题


I am trying to retrieve named ranges from excel file using the apache poi plugin.

The code snippet is as given below.

I see that call WorkbookFactory.create(excelFile); is taking a long time - about 3 seconds.

Is there a faster way of getting all the named ranges associated with excel sheet?

File excelFile = new File(filePath);
Workbook workbook = WorkbookFactory.create(excelFile);
int n = workbook.getNumberOfNames();

for (int i = 0; i < n; i++)
{
    Name nameObject = workbook.getNameAt(i);
    String formulaName = nameObject.getRefersToFormula();
    System.out.println("Named Range is :"+formulaName);
}

回答1:


I just submitted a patch to POI which fixes the horrible WorkbookFactory.create() execution time, you might want to look at it here:

https://issues.apache.org/bugzilla/show_bug.cgi?id=51585

Building POI is not really hard - just apply the patch to the vanilla 3.9 version.



来源:https://stackoverflow.com/questions/18957278/apache-poi-performance-issue-with-workbookfactory-create

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!