Copy and paste rows with HSSF (Apache POI)

ace picture ace · Apr 19, 2011 · Viewed 49k times · Source

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.

Answer

Ralph picture Ralph · Apr 19, 2011

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