0

I have an asp.net core application that uses Npoi to generate an Excel spreadsheet from a list of objects. This works fine when I run the application on my machine. However, when some of our users run this function, the dates on the spreadsheet are displaying 16 days earlier than their actual values. For example, the date 11/3/2020 is displaying 10/18/2020 for some users.

What's weird is if they email me the spreadsheet and I open it on my machine, the dates display correctly. Has anyone else run into this issue, or have a guess as to what might be causing this to happen? Also, any suggestions on how to fix it?

Your help is greatly appreciated. Thanks. -Joe

  • What kind of date format do they have in their Windows regional settings? – GSerg Nov 04 '20 at 21:49
  • I've sent an e-mail to the users, but probably won't hear back until tomorrow (as some of them are in India). Could the date format change the dates by 16 days? I know timezone differences could change the date by a day, but I'm having trouble seeing how the format could change it by 16 days. Am I missing something? – blue_thunder Nov 04 '20 at 22:17
  • Our users in India are using the English (India) format, with short date format of dd-MM-yyyy and long date format of dd MMMM yyyy. I have not gotten a response yet from the user in the U.S. that reported having this issue. – blue_thunder Nov 05 '20 at 13:20
  • A date wouldn't display as `10/18/2020` under a `dd-MM-yyyy` locale. The separators do not match, and the MM cannot be 18. Are you storing dates as dates in Excel, or as date-looking strings? – GSerg Nov 05 '20 at 14:26
  • The cell formatting in the spreadsheet is [$-en-US]m/d/yyyy, which is why the separators do not match. – blue_thunder Nov 05 '20 at 14:40
  • So, I had one of the users copy the date column from Excel and paste it into Notepad. When he did this, the date values displayed correctly in Notepad. So, I think it has to be some sort of issue with the formatting in Excel, but I have yet to figure out how to fix it. – blue_thunder Nov 05 '20 at 15:08

0 Answers0