How to preserve dates when copying rows with a CellCopyPolicy value for cellStyle set to false
Dan S <[email protected]> Tue, 11 Feb 2025 11:48:09 -0500
| Newsgroups | gmane.comp.jakarta.poi.user |
|---|---|
| Message-ID | <CANeOZMSnccSdVH1dy3O5YVVupEkp6gWBEVgW-xdgJ9K8fhs3Rw@mail.gmail.com> |
--000000000000a1c957062de0974d Content-Type: text/plain; charset="UTF-8" I hope I am addressing the right list. I am an Apache NIFI developer and I have developed an Apache NIFI processor named SplitExcel which splits a multi sheet Microsoft Excel spreadsheet into multiple Microsoft Excel spreadsheets where each sheet from the original file is converted to an individual spreadsheet. Source code for this can be found here <https://github.com/apache/nifi/blob/main/nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java> (lines 165-188). In order to accomplish this, I use the com.github.pjfanning.xlsx.StreamingReader to stream the Excel workbook which allows for easy looping over each sheet. I create a new XSSFWorkbook for each sheet there is in the existing workbook and I use XSSFSheet copyRows method to copy the rows from the existing sheet to a new sheet to place in the new XSSFWorkbook. The CellCopyPolicy used has cellStyle set to false in order to avoid exceeding the maximum number of cell styles (fixed in NIFI-13726 <https://issues.apache.org/jira/browse/NIFI-13726>). The drawback though of using cellStyle set to false is that any columns which have dates, its date formatting is lost and what is left is a meaningless number (reported in NIFI-14106 <https://issues.apache.org/jira/browse/NIFI-14106>). Is there a way I can use copyRows not to exceed the maximum number of cell styles and yet have the formatting needed for dates? --000000000000a1c957062de0974d--