阿帕奇浦二与WorkbookFactory.create性能问题() [英] Apache Poi performance issue with WorkbookFactory.create()

查看:3549
本文介绍了阿帕奇浦二与WorkbookFactory.create性能问题()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Apache POI插件检索excel文件的命名范围。

在code段是为如下。

我看到呼叫 WorkbookFactory.create(excelFile); 走的是一条很长一段时间 - 大约3秒。

有没有得到所有与Excel工作表关联的指定范围内的一个更快的方法?

 文件excelFile =新的文件(文件路径);
工作簿簿= WorkbookFactory.create(excelFile);
INT N = workbook.getNumberOfNames();的for(int i = 0; I< N;我++)
{
    命名nameObject = workbook.getNameAt(ⅰ);
    串formulaName = nameObject.getRefersToFormula();
    的System.out.println(命名的范围是:+ formulaName);
}


解决方案

我刚刚提交了一个补丁,POI,修正了可怕的WorkbookFactory.create()的执行时间,您可能希望看它这里:

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

建筑POI是不是真的很难 - 只有补丁应用到香草3.9版本

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);
}

解决方案

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.

这篇关于阿帕奇浦二与WorkbookFactory.create性能问题()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆