{"id":19169073,"url":"https://github.com/dreamph/go-excel","last_synced_at":"2025-10-28T08:51:30.702Z","repository":{"id":223243257,"uuid":"759695778","full_name":"dreamph/go-excel","owner":"dreamph","description":"Golang Read and Write Excel","archived":false,"fork":false,"pushed_at":"2024-08-22T11:30:13.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-22T10:27:15.443Z","etag":null,"topics":["excel","go-excel","golang","read-excel","write-excel"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dreamph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-19T06:49:08.000Z","updated_at":"2024-02-20T10:18:09.000Z","dependencies_parsed_at":"2024-02-29T06:28:48.951Z","dependency_job_id":"79e514de-bd3c-44c9-903b-add13318fd5f","html_url":"https://github.com/dreamph/go-excel","commit_stats":null,"previous_names":["dreamph/go-excel"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/dreamph/go-excel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fgo-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fgo-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fgo-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fgo-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreamph","download_url":"https://codeload.github.com/dreamph/go-excel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fgo-excel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281410760,"owners_count":26496368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excel","go-excel","golang","read-excel","write-excel"],"created_at":"2024-11-09T09:44:52.938Z","updated_at":"2025-10-28T08:51:30.685Z","avatar_url":"https://github.com/dreamph.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Basic Usage\n\n# Read\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"path/filepath\"\n\n\t\"github.com/dreamph/go-excel\"\n)\n\ntype Data struct {\n    ID   string\n    Name string\n    Age  int\n}\n\nfunc main() {\n    filePath := \"example/read/read.xlsx\"\n\texcelFile, err := excel.OpenFile(filepath.Clean(filePath))\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tdefer excel.Close(excelFile)\n\n\texcelReader := excel.NewReader(excelFile)\n\n\tvar result []Data\n\terr = excelReader.Read(\"Sheet1\", 1, func(rowIndex int, rowData []string) error {\n\t\tdata := Data{}\n\t\tdata.ID = rowData[0]\n\t\tdata.Name = rowData[1]\n\t\tresult = append(result, data)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t}\n\n\tfmt.Println(len(result))\n\n}\n```\n\n\n# Write\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"path/filepath\"\n\n\t\"fmt\"\n\n\t\"github.com/dreamph/go-excel\"\n)\n\nfunc main() {\n\tfilePath := \"example/write/write.xlsx\"\n\texcelFile, err := excel.OpenFile(filepath.Clean(filePath))\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tdefer excel.Close(excelFile)\n\n\texcelWriter := excel.NewWriter(excelFile)\n\tvar list []excel.DataRef\n\tfor i := 1; i \u003c 5; i++ {\n\t\tlist = append(list, excel.DataRef{SheetName: \"Sheet1\", CellName: fmt.Sprintf(\"C%d\", i), Data: \"Invalid Format\", TextColor: \"#1265BE\"})\n\t}\n\n\terr = excelWriter.WriteList(list)\n\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\n\terr = excelWriter.SaveAs(\"example/write/write_1.xlsx\")\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\n\t/*\n\t\tfileBytes, err := excel.ToBytes(excelFile)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(err.Error())\n\t\t}\n\t\tfmt.Println(fileBytes)\n\t*/\n}\n\n```\n\n\n# Export Excel\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/dreamph/go-excel\"\n)\n\ntype Customer struct {\n\tName     string `json:\"name\"`\n\tMobileNo string `json:\"mobileNo\"`\n}\n\nfunc GenerateCustomerData() *[]Customer {\n\tvar list []Customer\n\tfor i := 1; i \u003c= 10; i++ {\n\t\tlist = append(list, Customer{\n\t\t\tName:     fmt.Sprintf(\"Name%d\", i),\n\t\t\tMobileNo: fmt.Sprintf(\"00000000%d\", i),\n\t\t})\n\t}\n\treturn \u0026list\n}\n\nfunc main() {\n\t//GenerateExcelAsBytes for create excel by configs\n\tvar configs []excel.GenerateExcelConfig[Customer]\n\tconfigs = append(configs, excel.GenerateExcelConfig[Customer]{\n\t\tHeader: \"Name\",\n\t\tValue: func(obj *Customer) string {\n\t\t\treturn obj.Name\n\t\t},\n\t})\n\tconfigs = append(configs, excel.GenerateExcelConfig[Customer]{\n\t\tHeader: \"MobileNo\",\n\t\tValue: func(obj *Customer) string {\n\t\t\treturn obj.MobileNo\n\t\t},\n\t})\n\tdataList := GenerateCustomerData()\n\tdataBytes, err := excel.GenerateExcelAsBytes(\"Data\", excel.FirstRowIndex, \u0026configs, dataList)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\terr = WriteFile(\"test.xlsx\", dataBytes)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}\n\nfunc WriteFile(filePath string, bytes []byte) error {\n\tfile, err := os.Create(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func(file *os.File) {\n\t\t_ = file.Close()\n\t}(file)\n\n\t_, err = file.Write(bytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Fgo-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreamph%2Fgo-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Fgo-excel/lists"}