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

查看:71
本文介绍了将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)

模型类实现了 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天全站免登陆