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

How do I set the Time format and value of a cell? #330

Open
prateek-singh-3 opened this issue Sep 21, 2023 · 0 comments
Open

How do I set the Time format and value of a cell? #330

prateek-singh-3 opened this issue Sep 21, 2023 · 0 comments

Comments

@prateek-singh-3
Copy link

prateek-singh-3 commented Sep 21, 2023

Hello,

I am trying to set the format of a cell which contains time to HH:mm and value to HH:mm:ss and am using the below code to achieve this.

Set the value:
worksheet.Cell(row, pos + 2).SetValue(dday.Equals(string.Empty) ? string.Empty : ddayTime.Value.ToString("HH:mm:ss"));

Set the format:
worksheet.Cell(row, pos + 2).Style.DateFormat.SetFormat(XLPredefinedFormat.DateTime.Hour24Minutes.ToString());
worksheet.Cell(row, pos + 2).Style.DateFormat.Format = "HH:mm";

However the final value and format in the generated excel file are both "HH:mm:ss".
It was working fine with version 0.94.2 but stopped working after upgrading to 0.102.1

Any suggestions?

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