You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f := excelize.NewFile() defer func() { if err := f.Close(); err != nil { fmt.Println(err) } }() // 创建一个工作表 index, err := f.NewSheet("Sheet2") if err != nil { fmt.Println(err) return } // 设置单元格的值 f.SetCellValue("Sheet2", "A2", "Hello world.") f.SetCellValue("Sheet1", "B2", "234") // 设置工作簿的默认工作表 f.SetActiveSheet(index) // 根据指定路径保存文件 if err := f.SaveAs("Book1.xlsx"); err != nil { fmt.Println(err) }
I used the official codes, Book1.xlsx is generated, but when I opened it, there is no content in it.
Before this, I used stream method for download xlsx, it's very ok, the content is in it, but today I use SaveAs method, the content is empty. I send the Book1.xlsx to my other colleagues, they use Macs or PCs, they can't open it either, so I wanna know why I can't get the right content.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
goversion 1.21.0
excelize 2.8.1
f := excelize.NewFile() defer func() { if err := f.Close(); err != nil { fmt.Println(err) } }() // 创建一个工作表 index, err := f.NewSheet("Sheet2") if err != nil { fmt.Println(err) return } // 设置单元格的值 f.SetCellValue("Sheet2", "A2", "Hello world.") f.SetCellValue("Sheet1", "B2", "234") // 设置工作簿的默认工作表 f.SetActiveSheet(index) // 根据指定路径保存文件 if err := f.SaveAs("Book1.xlsx"); err != nil { fmt.Println(err) }
I used the official codes, Book1.xlsx is generated, but when I opened it, there is no content in it.
Before this, I used stream method for download xlsx, it's very ok, the content is in it, but today I use SaveAs method, the content is empty. I send the Book1.xlsx to my other colleagues, they use Macs or PCs, they can't open it either, so I wanna know why I can't get the right content.
Beta Was this translation helpful? Give feedback.
All reactions