Skip to content

feat: add support to set 1904 date system based on global configuration - #435

Merged
psxjoy merged 16 commits into
apache:mainfrom
delei:issue/feature-434
Jul 29, 2025
Merged

psxjoy merged 16 commits into
apache:mainfrom
delei:issue/feature-434

Conversation

@delei

@delei delei commented Jul 24, 2025 •

Copy link
Copy Markdown
Member

Purpose of the pull request

Closes: #433 , #434

What's changed?

These changes only for the xlsx file:

  • (write)use the setDate1904 method to set 1904 date system
  • (read)use user-set parameters instead of always using default values.
  • (read)add support for handle 1904 date windowing records

Checklist

  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@delei
delei marked this pull request as ready for review July 26, 2025 15:09

@alaahong alaahong left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please concern to add full test not only on the configuration value, it should be matching the result with configuration set.

XLS--> https://github.com/apache/poi/blob/bcc7912c8dc284e6f1b345c9295235ecf4fdce27/poi/src/main/java/org/apache/poi/hssf/model/InternalWorkbook.java#L1269

@delei

delei commented Jul 27, 2025

Copy link
Copy Markdown
Member Author

Please concern to add full test not only on the configuration value, it should be matching the result with configuration set.

Thank you for the information. I will check to see if it is supported.

@delei
delei marked this pull request as draft July 27, 2025 17:16
@delei

delei commented Jul 27, 2025

Copy link
Copy Markdown
Member Author

I will refactor the unit tests for datewindowing ASAP.

@delei
delei marked this pull request as ready for review July 27, 2025 18:08

@alaahong alaahong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to implement a feature, the unit test should not just run without any assertion or verify.

as you've achieve the major part, parameter for 1904 of xlsx, so just leave comment but no blocking here.

}

@Test
void test03WriteAndRead() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems no assertion or verify here. it should be throwing exception, or write warn log to keep no breaking change at least.
but the test highlight that FastExcel won't support but test pass with a true value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, others assertions in class DateWindowingListener

@psxjoy psxjoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not checking this PR in time. I don't see any issues with it, and once @alaahong confirms that it's fine, I will merge the PR within 24 hours.

@psxjoy psxjoy added this to the 1.3.0 milestone Jul 28, 2025

@alaahong alaahong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. just leave a question for detail, please kindly help to check if you've a time.

.excelType(ExcelTypeEnum.XLS)
.use1904windowing(Boolean.TRUE)
.sheet()
.doWrite(data());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may I ask for this setting behavior? will the excel show the 1904 model since wrote with true?
image

@delei delei Jul 28, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,only xlsx is supported,writing to xls is not supported.If the provided files have been set up using MS Excel, there will be no problem reading xls files.
I have provided two xls files that have been set up for testing the reading of xls files.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using org.apache.poi.hssf.model.InternalWorkbook#createWorkbook(), but it couldn't set this option in the actual file. I think Apache POI no longer supports this.

https://github.com/apache/poi/blob/bcc7912c8dc284e6f1b345c9295235ecf4fdce27/poi/src/main/java/org/apache/poi/hssf/model/InternalWorkbook.java#L1269-L1274

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InternalWorkbook#createWorkbook() always set false ~so I thought above case still involving some confused

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞Me too. I haven't found a way to set this for xls files yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the test case should be same behavior if always set false by POI. Might be we can reflect to get the value in unit test, just fetch the value but not set to avoid any hack on private field.

@psxjoy
psxjoy merged commit f567054 into apache:main Jul 29, 2025
@delei
delei deleted the issue/feature-434 branch July 29, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Unable to set use1904windowing when reading xlsx files

3 participants