-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support date formats with dot separator such as DD.MM.YYYY #7
Comments
Thanks for your issue. I have tested number format code |
Sorry for not adding more context. Let me rectify: The problem occurs when the datetime is stored as a float in the specific cell rather than a shared string, and a custom format code is used. See this example: package main
import (
"fmt"
"log"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
log.Fatal(err)
}
}()
activeSheetName := f.GetSheetName(f.GetActiveSheetIndex())
f.SetCellValue(activeSheetName, "A1", 45186.0)
exp := "DD.MM.YYYY"
style, _ := f.NewStyle(&excelize.Style{CustomNumFmt: &exp})
f.SetColStyle(activeSheetName, "A", style)
val, _ := f.GetCellValue(activeSheetName, "A1")
fmt.Println(val) // Getting '..2023'. Want '17.09.2023'
} During execution, the circumstances lead to this line in the excelize codebase to be run, which ultimately lead to I have addressed the issue in #8 |
Is your feature request related to a problem? Please describe.
When using excelize to read an Excel workbook with dates formatted as DD.MM.YYYY it results in
..YYYY
, e.g.18.11.2023
is parsed as..2023
.Describe the solution you'd like
Once the parser sees the dot
.
, it interprets this as aTokenTypeDecimal
and discards the preceding datetime values, e.g. parsingMM.
results in a.
token.I want to see an
MM
token ofTokenTypeDatetime
and a.
of typeTokenTypeLiteral
being added to the tokens list.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: