Re: How to copy an HSSFSheet into another HSSFSheet which belongs to a different HSSFWorkbook.
PJ Fanning <[email protected]> Tue, 13 May 2025 17:23:14 +0100
| Newsgroups | gmane.comp.jakarta.poi.user |
|---|---|
| Message-ID | <CAMRKCNE5gEBY6Frj7uXGyJaG87mxvy2a-n20nZ+jWRQhAWT21A@mail.gmail.com> |
Please raise a bug in bugzilla. POI is a volunteer project and I am currently busy and don't have a lot of time to devote to unpaid work. On Tue, 13 May 2025 at 15:41, Dan S <[email protected]> wrote: > > PJ, > I am trying to use the copyRows as you suggested but I am hitting some e= xceptions regarding formulas even though my data has no formulas. I took a = unit test of mine in which I was testing the bug I reported in https://bz.a= pache.org/bugzilla/show_bug.cgi?id=3D69583 and refitted it with an HSSFWork= book along with my code which creates a new Workbook from each Sheet of an = existing Workbook. The unit code test is included as an attachment. The sta= cktrace I get is: > > [main] WARN org.apache.poi.POIDocument - DocumentSummaryInformation prope= rty set came back as null > [main] WARN org.apache.poi.POIDocument - SummaryInformation property set = came back as null > > java.lang.IllegalStateException: Cannot get a FORMULA value from a STRING= formula cell > > at org.apache.poi.hssf.usermodel.HSSFCell.typeMismatch(HSSFCell.java:648) > at org.apache.poi.hssf.usermodel.HSSFCell.getCellFormula(HSSFCell.java:64= 0) > at org.apache.poi.hssf.usermodel.helpers.HSSFRowColShifter.updateRowFormu= las(HSSFRowColShifter.java:74) > at org.apache.poi.hssf.usermodel.helpers.HSSFRowShifter.updateRowFormulas= (HSSFRowShifter.java:71) > at org.apache.poi.hssf.usermodel.HSSFRow.copyRowFrom(HSSFRow.java:853) > at org.apache.nifi.excel.TestHSSFRowCopyRowFrom.test(TestHSSFRowCopyRowFr= om.java:74) > at java.base/java.lang.reflect.Method.invoke(Method.java:580) > at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) > at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) > > > > On Mon, May 12, 2025 at 6:32=E2=80=AFPM Dan S <[email protected]> wrote: >> >> PJ, >> Thank you! That is very helpful and aligns very well with the XSSFSheet = copyRows method in regards to use of CellCopyPolicy and CellCopyContext. >> >> On Mon, May 12, 2025 at 5:49=E2=80=AFPM PJ Fanning <[email protected]= > wrote: >>> >>> There is copyRowFrom in HSSFRow. >>> >>> https://poi.apache.org/apidocs/dev/org/apache/poi/hssf/usermodel/HSSFRo= w.html#copyRowFrom-org.apache.poi.ss.usermodel.Row-org.apache.poi.ss.usermo= del.CellCopyPolicy-org.apache.poi.ss.usermodel.CellCopyContext- >>> >>> On Mon, 12 May 2025 at 21:54, Dan S <[email protected]> wrote: >>> > >>> > XSSFSheet has a copyRows method which allows for copying the contents= of >>> > one XSSFSheet to another one. I do not see an equivalent method for a= n >>> > HSSFSheet. I see from this post >>> > <https://lists.apache.org/[email protected]:dfr=3D2020-1-1|dto= =3D2025-5-12:HSSFSheet%20copy> >>> > a solution which allows copying for HSSFSheet and XSSFSheet. I just w= ant to >>> > make sure if that is a recommended way for HSSF and if not has there = been >>> > any change to POI that provides methods for this? >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected]