使用HSSF复制和粘贴行(Apache POI)[重复]

时间:2021-12-18 20:25:40

Possible Duplicate:
How to insert a row between two rows in an existing excel with HSSF (Apache POI)

可能重复:如何使用HSSF(Apache POI)在现有Excel中的两行之间插入行

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.

如何使用HSSF复制行的值和所有格式。使用MS Excel或其他Spread Sheet应用程序,可以轻松复制和粘贴。但现在我在使用Java中的HSSF复制行时遇到问题。

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.

我现在的情景是,我在Cell:A46上,它是表格的最后一行,但我仍然有很多数据要填充在单元格上。我不能简单地只创建一行和它的单元格,因为我还需要格式化。它也可能会破坏一些公式,因为我使用了一个excel模板,它在Cell:A46之后有格式化。

2 个解决方案

#1


3  

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

顺便说一句:如果您需要处理样式信息,那么请查看JXLS。它基于POI,可用于(例如)从基于Excel文件的模板填充Excel文件

#2


3  

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

对于答案,请在这里查看我的其他帖子

#1


3  

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

顺便说一句:如果您需要处理样式信息,那么请查看JXLS。它基于POI,可用于(例如)从基于Excel文件的模板填充Excel文件

#2


3  

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

对于答案,请在这里查看我的其他帖子