使用 HSSF (Apache POI) 复制并粘贴行
如何使用 HSSF 复制行的值和所有格式。使用 MS Excel 或其他电子表格应用程序,就像复制和粘贴一样简单。但现在我在 Java 中使用 HSSF 复制行时遇到问题。
我现在的情况是,我位于单元格:A46 上,它是表格的最后一行,但我仍然有许多数据要填充到单元格上。我不能简单地创建一行及其单元格,因为我还需要格式化。而且它也可能会破坏一些公式,因为我使用的 Excel 模板在 Cell:A46 之后具有格式。
Possible Duplicate:
How to insert a row between two rows in an existing excel with HSSF (Apache POI)
How can I copy the values and all the formatting of a row using HSSF. Using the MS Excel or other Spread Sheet application it is easy as copy and paste. But now I'm having problem copying a row with HSSF in Java.
My scenario right now, is I'm on the Cell:A46 and it is the last row of the table, but I still have many data to populate on the cell. I cannot simply just create a row and it cells, because I need also the formatting. And it may also break some of the formulas, because I use an excel template which have formatting after Cell:A46.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不迭代单元格,并在新行上创建一个新单元格并从“旧”单元格复制布局信息?
顺便说一句:如果您需要处理可能的样式信息,请查看 JXLS。它基于 POI,并可用于(例如)从基于 Excel 文件的模板填充 Excel 文件
Why do you not iterate trough the cells, and creating a new cell on the new row and copy the layout information from the "old" one?
BTW: If you have to do with may style information, then have a look at JXLS. It is based on POI and an be used (for example) to populate Excel files, from Excel-file based templates
我写了一篇类似的文章,其中有解决这个问题的答案。
要找到答案,请查看我的另一篇文章 此处
I did a similar post that have an answer which solve this problem.
For the answer, just take a look on my other post here