-
-
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
Read date/time from the cell #73
Comments
I will explain the problem: In the Excel file there is a cell: I'm trying to get it...
Output: "42915.395" |
Do you mean |
xlsx? |
This library just support Excel's built-in formats currently. The built-in formats
|
Now it is clear. Thank you! |
I am not sure I understand how SetCellStyle works.
With this in mind the following makes perfect sense
However, when I tried for
The format seems to match the comment, so I'm not sure what I am missing. Bonus question: |
Nevermind, it is probably easier to convert the excel date to a time.Time.
|
My date is in the format |
when upgrade v2.3.1 to v2.3.2 err := xlsx.SetCellStyle("sheet1", "A1", "A1", 0)
if err != nil {
// do something
}
label, err := xlsx.GetCellValue("sheet1", "A1")
if err != nil {
// do something
}
f, err := strconv.ParseFloat(label, 64)
if err != nil {
// do something
}
t, err = excelize.ExcelDateToTime(f, false)
if err != nil {
// do something
} |
You can change the format of the output date as follows, with func ExcelSerialDateToTime(serial string) string {
days, _ := strconv.Atoi(serial)
convertedTime := excelEpoch.Add(time.Second * time.Duration(days*86400)).Format("01-2-2006")
return convertedTime
} |
ParseFloat works better if you need time not just days: func toDate(excelDate string) time.Time {
var days, _ = strconv.ParseFloat(excelDate, 64)
return excelEpoch.Add(time.Second * time.Duration(days*86400))
} |
Hy everyone, is there any update regarding date issue? |
parsedDate, parsedDateErr := time.Parse("01-02-2006", "04-04-2023") Maybe someone give you better answer) Good luck |
How to correctly read the date/time from the cell?
The text was updated successfully, but these errors were encountered: