English 中文(简体)
如何检查工作表是否存在?
原标题:How to check if sheet exist?

I want to check whether given sheet (by name or number) exists in the file (xls or xlsx) before I read it. I am using Event API to address memory footprint issue and thus I don t want to use org.apache.poi.ss.usermodel.Workbook object.

我用阿帕契3.7和JDK7,谁能帮我一下吗?

谢谢

帕拉g

最佳回答

使用用户模式代码的检查方式与两种格式相同。

然而,您已经询问了事件 API 的情况。 这些级别要低得多, 所以两种格式之间的差异必须由您来处理, 因为两者之间没有任何可以隐藏的。 (如果您想要轻松的生活, 请为您的服务器购买更多的内存, 并粘贴用户模式! )

对于.xls 文件格式 (HSSF), 工作表的详情存储在文件顶部附近。 开始处理文件, 等待 BoundSheetRecord (sid= 0x0085) 的过去。 如果您已经看到所有这些, 您就会知道工作表是否在文件中。 如果工作表是正常的, 则按正常程序进行 。 否则, 中止 。

对于.xlsx 文件格式 (XSSF), 打开文件并抓取工作簿部分( 它相当小 ) 。 检查是否有工作簿, 如果您想要处理或不处理, 然后根据此决定。 如果您正在使用 XSSFReader, 请调用 < code> getWorkbookData () 来获取工作簿部分, 然后可能使用 Xmlbeans 来处理它( 通过 < code> WorkbookDocument. factory ) 。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...