Skip to content
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

Issue in reading Date values from excel file for dd/mm/yyyy using GetFormattedString() methods #2286

Open
1 of 5 tasks
vineethkasula opened this issue Feb 5, 2024 · 0 comments

Comments

@vineethkasula
Copy link

vineethkasula commented Feb 5, 2024

Read and complete the full issue template

Do not randomly delete sections. They are here for a reason.

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • [X ] Yes
  • No

If you answered No, please test with the latest development build first.

Version of ClosedXML

e.g. 0.102.2

What is the current behavior?
while reading date cell value from an excel file (cell format is set to dd/mm/yyyy) through GetFormattedString() or GetValue() methods to read value it's format is changed to mm/dd/yyyy.

What is the expected behavior or new feature?
we expect the value should be same as displayed in excel file when using GetFormattedString() methods

Is this a regression from the previous version?
Not sure

Reproducibility

This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.

  1. create an excel file just input date in dd/mm/yyyy format, set the cell format in excel file to dd/mm/yyyy.
  2. add the date in 1st row and 1st column of the sheet.
  3. verify that variable "formattedDateStr" is read in mm/dd/yyyy and it is not same as displayed in excel file.

UPDATE: seems like cell which is in system format mm/dd/yyyy, is failing to convert correctly. Attached screenshot
Screenshot 2024-02-06 at 08 44 16

example: Input 03/01/2024 in excel file, but when its read using GetFormattedString() observe that it's read as 1/3/2024.

Code to reproduce problem:

public void Main()
{
   string filePath  = "";
   using XLWorkbook workbook = new XLWorkbook(filePath);
   var formattedDateStr = workbook.Worksheet(0).Cell(1, 1).GetFormattedString();
  Console.WriteLine(formattedDateStr);
}
  • I attached a sample spreadsheet. (You can drag files on to this issue)
@vineethkasula vineethkasula changed the title Issue in reading Date values from excel file for dd/mm/yyyy format Issue in reading Date values from excel file for dd/mm/yyyy using GetFormattedString() methods Feb 5, 2024
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

No branches or pull requests

1 participant