Reputation: 11
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);
}
Upvotes: 1
Views: 3174
Reputation: 99
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.
Upvotes: 1