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

Excel time always output in float format using StreamWriter #1107

Closed
KuanYuLai opened this issue Dec 29, 2021 · 3 comments
Closed

Excel time always output in float format using StreamWriter #1107

KuanYuLai opened this issue Dec 29, 2021 · 3 comments

Comments

@KuanYuLai
Copy link

Description

I try to output excel time from time.Time variable using streamWriter, however, it seems like the value will always be in float format.

Steps to reproduce the issue:

  1. Create variable in time.Time type
  2. Write to excel using stream writer

Describe the results you received:
float format: 44090.5179861111

Describe the results you expected:
excel time format: 2021/12/29 19:26

Output of go version:

go version go1.17.5 darwin/arm64

Excelize version or commit ID:

excelize/v2 v2.4.2

Environment details (OS, Microsoft Excel™ version, physical, etc.):
OS: Mac with M1 chip
Microsoft Excel: Mac Version 16.12 (180410)

@xuri
Copy link
Member

xuri commented Dec 29, 2021

Thanks for your feedback, please create a style with number format, and bind style ID for the cell in streaming writing.

@KuanYuLai
Copy link
Author

ok! Thanks for the solution, may I know the reason why stream writer won't convert Time variable to excel time automatically?

@xuri xuri closed this as completed in e37e060 Dec 30, 2021
@xuri
Copy link
Member

xuri commented Dec 30, 2021

Thanks for your issue, I've to make stream writer auto-create a time number format for time type cells, and this feature will be released in the next version.

jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…at for time type cells

Unit test coverage improved
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

2 participants