无法使用 Apache POI 在 Word 文档 (.doc) 中获取/设置复选框值 [英] couldn't get/set checkbox value in Word document (.doc) with Apache POI

查看:50
本文介绍了无法使用 Apache POI 在 Word 文档 (.doc) 中获取/设置复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Apache POI 在 Word 文档 (.doc) 中获取/设置复选框值.

I'm trying to get/set checkbox value in Word document (.doc) with Apache POI.

我在 poi.apache.org 上查看了 HWPFDocument API,但没有找到任何合适的...也许有人有解决方案?

I looked HWPFDocument API at poi.apache.org, but haven't found anything suitable... Maybe somebody have a solution?

谢谢!

推荐答案

遗憾的是,POI 目前不支持此功能.有效的是通过 CharacterRun.getDropDownListValues()CharacterRun.getDropDownListDefaultItemIndex().

Unfortunately, this is currently not supported by POI. What does work is to read out (not set) dropdown lists via CharacterRun.getDropDownListValues() and CharacterRun.getDropDownListDefaultItemIndex().

不过,从技术上讲,这些下拉列表与复选框密切相关.因此,如果需要,将相应的功能添加到 POI 应该不会太困难.您的入口点是一个 NilPICFAndBinData 结构(由 POI 中的 此类 处理),这会引导您找到一些 FFData(映射到 POI 中的此类).您会在其中找到 FFDataBits.这些最终包含一个 iRes 值,该值对该复选框的状态进行编码.- 这与下拉列表的行为完全相同,只是 FFDataBits 的 iType 将是 iTypeChck 而不是 iTypeDrop 并且必须被解释以稍微不同的方式.

Technically those dropdown lists are closely related to checkboxes, though. So it should not be too difficult to add the respective functionality to POI, if desired. Your entry point is a NilPICFAndBinData structure (handled by this class in POI), which leads you to some FFData (maps to this class in POI). Inside that you will find FFDataBits. These eventually contain an iRes value which encodes the status of that checkbox. - This is exactly the same behavior as for dropdown lists, only that the iType of FFDataBits will be iTypeChck instead of iTypeDrop and has to be interpreted in a slightly different way.

这篇关于无法使用 Apache POI 在 Word 文档 (.doc) 中获取/设置复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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