We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Description
Generating big table with time columns output file is corrupted.
Steps to reproduce the issue: here is example script `package main
import ( "flag" "fmt" "github.com/360EntSecGroup-Skylar/excelize" "math/rand" "reflect" "strconv" "time" )
type NullTime struct { Time time.Time Valid bool // Valid is true if Time is not NULL }
func main() { r := rand.New(rand.NewSource(99))
excel := excelize.NewFile() sheetName := "Test sheet" sheetIndex := excel.GetActiveSheetIndex() excel.SetSheetName(excel.GetSheetName(sheetIndex), sheetName) dateStyle, _ := excel.NewStyle(`{"custom_number_format": "yyyy-mm-dd"}`) floatStyle, _ := excel.NewStyle(`{"number_format": 2}`) rowsCount := flag.Int("rows", 100, "Number of rows") flag.Parse() for row := 1; row <= *rowsCount; row++ { for col := 1; col <= 10; col++ { val := randate() t := reflect.ValueOf(val) _ = excel.SetCellValue(sheetName, intToCharIndex(col)+strconv.Itoa(row), t.Interface()) _ = excel.SetCellStyle(sheetName, intToCharIndex(col)+strconv.Itoa(row), intToCharIndex(col)+strconv.Itoa(row), dateStyle) } for col := 11; col <= 101; col++ { _ = excel.SetCellValue(sheetName, intToCharIndex(col)+strconv.Itoa(row), r.Float64()) _ = excel.SetCellStyle(sheetName, intToCharIndex(col)+strconv.Itoa(row), intToCharIndex(col)+strconv.Itoa(row), floatStyle) } } if err := excel.SaveAs("Test.xlsx"); err != nil { fmt.Println(err) }
}
func intToCharIndex(i int) string { col, _ := excelize.ColumnNumberToName(i+1) return col }
func randate() time.Time { min := time.Date(2010, 1, 0, 0, 0, 0, 0, time.UTC).Unix() max := time.Date(2020, 1, 0, 0, 0, 0, 0, time.UTC).Unix() delta := max - min
sec := rand.Int63n(delta) + min return time.Unix(sec, 0).UTC()
`
making some 100 or 1000 rows output file is ok, making 10k rows file is corrupted.
Describe the results you received:
Describe the results you expected:
Output of go version:
go version
go version go1.14.2 darwin/amd64
Excelize version or commit ID:
v2.2.0
Environment details (OS, Microsoft Excel™ version, physical, etc.):
macOS Catalina, MS Excel for Mac 16.37
The text was updated successfully, but these errors were encountered:
a546427
Thanks for your issue. I have fixed it. Please try to upgrade the library with the master branch code.
Sorry, something went wrong.
Great, thank you for fast reaction.
Resolve qax-os#643, avoid creating duplicate style
2ff7bed
22a4cc2
No branches or pull requests
Description
Generating big table with time columns output file is corrupted.
Steps to reproduce the issue:
here is example script
`package main
import (
"flag"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"math/rand"
"reflect"
"strconv"
"time"
)
type NullTime struct {
Time time.Time
Valid bool // Valid is true if Time is not NULL
}
func main() {
r := rand.New(rand.NewSource(99))
}
func intToCharIndex(i int) string {
col, _ := excelize.ColumnNumberToName(i+1)
return col
}
func randate() time.Time {
min := time.Date(2010, 1, 0, 0, 0, 0, 0, time.UTC).Unix()
max := time.Date(2020, 1, 0, 0, 0, 0, 0, time.UTC).Unix()
delta := max - min
}
`
making some 100 or 1000 rows output file is ok, making 10k rows file is corrupted.
Describe the results you received:
Describe the results you expected:
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
macOS Catalina, MS Excel for Mac 16.37
The text was updated successfully, but these errors were encountered: