You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
在一些大量格式模板不同的excel表格录入的功能中,需要按配置设置表头格式,严格校验模板和数据,表头存在行列合并的情况,目前hutool读取到合并的单元格时只能读到合并区间的第一个单元格的值,其它的都是null,希望能有一种方式能拿到单元格所属区域的第一个单元格的值。
比如:
年度 户主姓名 户主身份证号码 产业种类及规模 产业种类及规模 产业种类及规模 产业种类及规模
年度 户主姓名 户主身份证号码 种植业(亩) 种植业(亩) 林果业(亩) 林果业(亩)
年度 户主姓名 户主身份证号码 玉米 小杂粮 苹果 苹果
年度 户主姓名 户主身份证号码 玉米 小杂粮 种植面积 挂果面积
在配置文件中,表头配置为:年度,户主姓名,户主身份证号码,产业种类及规模- 种植业(亩) -玉米,产业种类及规模- 种植业(亩) -小杂粮,产业种类及规模-林果业(亩)- 苹果-种植面积,产业种类及规模-林果业(亩)- 苹果-挂果面积。
模板按照 优先从左向右,其次从上向下的原则合并了单元格,对客户来说,这样更美观清晰,读取的时候,每一列的标题上下拼接,遇到合并单元格,取其合并区域的第一个值,上下相邻的标题如果相同只拼接一个,这样读取的配置就和配置一样了。
曾经有个系统需要快速导入导出大量格式模板不同的excel表格,标题复杂,列数较多,客户为普通的基层工作者,模板要清晰直观,而且经常变动,必须校验模板格式和数据,我就使用xml配置的方式,将日期格式、前缀、后缀、数字格式化、字典转换,标注说明都配置在xml中,根据这个配置来自动生成模板,读取数据并校验返回提示信息,当时自己封装的sax模式,挺好用的,就是封装的比较挫,看到这里有excel相关的功能,好像处理不了这种复杂表头模板。
Beta Was this translation helpful? Give feedback.
All reactions