Re: How to copy an HSSFSheet into another HSSFSheet which belongs to a different HSSFWorkbook.
Dan S <[email protected]> Tue, 13 May 2025 13:12:13 -0400
| Newsgroups | gmane.comp.jakarta.poi.user |
|---|---|
| Message-ID | <CANeOZMSrjsw6UvZePHiiEz1ztOCvHXFuaKWnZD43mqhjMJN0=A@mail.gmail.com> |
--000000000000444eec06350789c4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Submitted https://bz.apache.org/bugzilla/show_bug.cgi?id=3D69688 On Tue, May 13, 2025 at 12:26=E2=80=AFPM PJ Fanning <[email protected]> w= rote: > 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 > exceptions 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.apache.org/bugzilla/show_bug.cgi?id=3D69583 and refitted it wi= th > an HSSFWorkbook 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 stacktrace I get is: > > > > [main] WARN org.apache.poi.POIDocument - DocumentSummaryInformation > property set came back as null > > [main] WARN org.apache.poi.POIDocument - SummaryInformation property se= t > 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:64= 8) > > at > org.apache.poi.hssf.usermodel.HSSFCell.getCellFormula(HSSFCell.java:640) > > at > org.apache.poi.hssf.usermodel.helpers.HSSFRowColShifter.updateRowFormulas= (HSSFRowColShifter.java:74) > > at > org.apache.poi.hssf.usermodel.helpers.HSSFRowShifter.updateRowFormulas(HS= SFRowShifter.java:71) > > at org.apache.poi.hssf.usermodel.HSSFRow.copyRowFrom(HSSFRow.java:853) > > at > org.apache.nifi.excel.TestHSSFRowCopyRowFrom.test(TestHSSFRowCopyRowFrom.= 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 XSSFShee= t > 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]= rg> > wrote: > >>> > >>> There is copyRowFrom in HSSFRow. > >>> > >>> > https://poi.apache.org/apidocs/dev/org/apache/poi/hssf/usermodel/HSSFRow.= html#copyRowFrom-org.apache.poi.ss.usermodel.Row-org.apache.poi.ss.usermode= l.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 > an > >>> > HSSFSheet. I see from this post > >>> > < > https://lists.apache.org/[email protected]:dfr=3D2020-1-1|dto=3D20= 25-5-12:HSSFSheet%20copy > <https://lists.apache.org/[email protected]:dfr=3D2020-1-1%7Cdto= =3D2025-5-12:HSSFSheet%20copy> > > > >>> > a solution which allows copying for HSSFSheet and XSSFSheet. I just > want to > >>> > make sure if that is a recommended way for HSSF and if not has ther= e > 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] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --000000000000444eec06350789c4--