-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date Cells in Excel Exported as Numbers Instead of Dates #1917
Comments
By the way, my version is |
Ha, you fix it. thanks |
I encountered an issue while working with Excel files. Specifically, when I read a Date type cell (including its style), modify some values, and then write it to another Excel file using
SetCellStr
andSetCellStyle
, the date cell in the new Excel file appears as a number. However, the cell value remains a string. If I attempt to edit the cell, its value changes to a number reflecting an Excel date day.During debugging, I observed that the
GetCellStyle
function calls theextractNumFmt
function to read the NumFmt from Excel, and thexf.NumFmtID
property has the correct value forCustomNumFmt
(like 178 foryyyy/mmmm
etc.).The problem seems to occur because the range
s.NumFmts.NumFmt
does not correctly find the appropriate NumFmt forstyle.NumFmt
, leading to the value error.To resolve this, I added a piece of code to stop the loop when it finds the correct NumFmtID. This adjustment corrected the issue for various formats, such as currency, date, and precision.
Here’s the modified code:
The text was updated successfully, but these errors were encountered: