Bugfix: create worksheet cause file issue. Relate issue #249.
This commit is contained in:
parent
79dfe1c307
commit
a3571ee39b
|
@ -15,7 +15,7 @@ func parseFormatCommentsSet(formatSet string) (*formatComment, error) {
|
||||||
Author: "Author:",
|
Author: "Author:",
|
||||||
Text: " ",
|
Text: " ",
|
||||||
}
|
}
|
||||||
err := json.Unmarshal(parseFormatSet(formatSet), &format)
|
err := json.Unmarshal([]byte(formatSet), &format)
|
||||||
return &format, err
|
return &format, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -771,10 +771,6 @@ func TestAddTable(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
err = xlsx.AddTable("Sheet2", "A2", "B5", ``)
|
|
||||||
if err != nil {
|
|
||||||
t.Log(err)
|
|
||||||
}
|
|
||||||
err = xlsx.AddTable("Sheet2", "A2", "B5", `{"table_name":"table","table_style":"TableStyleMedium2", "show_first_column":true,"show_last_column":true,"show_row_stripes":false,"show_column_stripes":true}`)
|
err = xlsx.AddTable("Sheet2", "A2", "B5", `{"table_name":"table","table_style":"TableStyleMedium2", "show_first_column":true,"show_last_column":true,"show_row_stripes":false,"show_column_stripes":true}`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
10
sheet.go
10
sheet.go
|
@ -132,9 +132,17 @@ func (f *File) setSheet(index int, name string) {
|
||||||
// allowed in sheet title.
|
// allowed in sheet title.
|
||||||
func (f *File) setWorkbook(name string, rid int) {
|
func (f *File) setWorkbook(name string, rid int) {
|
||||||
content := f.workbookReader()
|
content := f.workbookReader()
|
||||||
|
rID := 0
|
||||||
|
for _, v := range content.Sheets.Sheet {
|
||||||
|
t, _ := strconv.Atoi(v.SheetID)
|
||||||
|
if t > rID {
|
||||||
|
rID = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rID++
|
||||||
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
|
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
|
||||||
Name: trimSheetName(name),
|
Name: trimSheetName(name),
|
||||||
SheetID: strconv.Itoa(rid),
|
SheetID: strconv.Itoa(rID),
|
||||||
ID: "rId" + strconv.Itoa(rid),
|
ID: "rId" + strconv.Itoa(rid),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue