Apache POI HSSF/XSSF 到 XLS/XLSX 的映射 [英] Mapping of Apache POI HSSF/XSSF to XLS/XLSX

查看:38
本文介绍了Apache POI HSSF/XSSF 到 XLS/XLSX 的映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache POI 4.x 在这里.我看到有两种类型的 Workbook 实现:

Apache POI 4.x here. I see there are two types of Workbook implementations:

  • HSSF 工作簿
  • XSSF 工作簿

我需要编写一个 Java 8 应用程序来读取带有.xls"(XLS)或.xlsx"(XLSX)扩展名的 Excel 表格.意思是,以旧"(2003 年之前)格式或较新格式保存的 Excel 文件.

I need to write a Java 8 app that reads Excel sheets with either ".xls" (XLS) or ".xlsx" (XLSX) extensions. Meaning, Excel files that were saved in the "old" (pre 2003) format, or the newer one.

假设我对 XLS 文件使用 HSSF,对 XLSX 文件使用 XSSF 是否安全?或者那里的映射逻辑有点复杂?这个答案似乎表明我是正确的,但这并不能让我完全确定我理解映射和HSSF 与 XSSF 的何时使用"逻辑.

Is it safe to assume I use HSSF for XLS files, and XSSF for XLSX files? Or is the mapping logic a little bit more complicated there? This answer seems to indicate I'm correct, but that doesn't leave me feeling totally sure that I understand the mapping and "when to use" logic of HSSF vs XSSF.

我已经搜索了 POI 文档,但无法为我的生活找到明确的答案.

I've scoured the POI documentation but can't find a clear answer for the life of me.

推荐答案

HSSF (org.apache.poi.hssf.usermodel 包) 适用于 XLS 文件格式

HSSF (org.apache.poi.hssf.usermodel package) is for XLS files format

XSSF(org.apache.poi.xssf.usermodel 包)用于 XLSX 文件格式(较新的一种)

XSSF (org.apache.poi.xssf.usermodel package) is for XLSX files format (newer one)

来自两个包(xssf 和 hssf)的模型类实现了来自 org.apache.poi.ss.usermodel 包的通用接口.因此,您可能可以使用 ss 包编写代码,并且它将与 xssf 或 hssf 上的抽象一起使用.

Model classes from both packages (xssf and hssf) implements common interfaces from org.apache.poi.ss.usermodel package. So, you potentially can write a code using ss package and it will work with abstractions over xssf or hssf.

这篇关于Apache POI HSSF/XSSF 到 XLS/XLSX 的映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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