Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created July 5, 2025 09:38
Show Gist options
  • Save kuc-arc-f/11cf48c026a9dc2e84a18637ad2fa705 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/11cf48c026a9dc2e84a18637ad2fa705 to your computer and use it in GitHub Desktop.
Golang Excel edit example
package main
import "github.com/xuri/excelize/v2"
func main() {
f := excelize.NewFile()
defer f.Close()
// 新規シート作成&セル書き込み
var shht_name = "Sheet1"
idx, _ := f.NewSheet(shht_name)
f.SetCellValue(shht_name, "A2", "こんにちは")
f.SetCellValue(shht_name, "B2", 123)
f.SetCellValue(shht_name, "A3", "hoge2")
f.SetCellValue(shht_name, "B3", 456)
f.SetActiveSheet(idx)
if err := f.SaveAs("sample.xlsx"); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment