{"id":13413432,"url":"https://github.com/szyhf/go-excel","last_synced_at":"2026-01-31T16:17:23.687Z","repository":{"id":40636995,"uuid":"102260918","full_name":"szyhf/go-excel","owner":"szyhf","description":"A simple and light excel file reader to read a standard excel as a table faster | 一个轻量级的Excel数据读取库，用一种更`关系数据库`的方式解析Excel。","archived":false,"fork":false,"pushed_at":"2025-05-08T02:39:39.000Z","size":296,"stargazers_count":195,"open_issues_count":1,"forks_count":40,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T03:31:36.136Z","etag":null,"topics":["go","golang","reader","xlsx"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szyhf.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}},"created_at":"2017-09-03T11:51:58.000Z","updated_at":"2025-05-08T02:37:24.000Z","dependencies_parsed_at":"2024-01-08T15:34:42.563Z","dependency_job_id":null,"html_url":"https://github.com/szyhf/go-excel","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/szyhf/go-excel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szyhf%2Fgo-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szyhf%2Fgo-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szyhf%2Fgo-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szyhf%2Fgo-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szyhf","download_url":"https://codeload.github.com/szyhf/go-excel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szyhf%2Fgo-excel/sbom","scorecard":{"id":864465,"data":{"date":"2025-08-11","repo":{"name":"github.com/szyhf/go-excel","commit":"8da7d4238dcd2b32429134444bd8f2e377330ff3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 3/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T02:17:55.637Z","repository_id":40636995,"created_at":"2025-08-24T02:17:55.637Z","updated_at":"2025-08-24T02:17:55.637Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28947573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","golang","reader","xlsx"],"created_at":"2024-07-30T20:01:40.257Z","updated_at":"2026-01-31T16:17:23.672Z","avatar_url":"https://github.com/szyhf.png","language":"Go","readme":"# Intro | 简介\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/szyhf/go-excel)](https://goreportcard.com/report/github.com/szyhf/go-excel)\n![cover.run go](https://cover.run/go/github.com/szyhf/go-excel.svg?tag=golang-1.10)\n[![GoDoc](https://godoc.org/github.com/szyhf/go-excel?status.png)](https://godoc.org/github.com/szyhf/go-excel)\n\nExpect to create a reader library to read relate-db-like excel easily.\nJust like read a config.\n\n\u003e This library can read all xlsx file correctly from our project now.\n\n```shell\ngo get github.com/szyhf/go-excel\n```\n\n## Example | 用例\n\nHere is a simple example.\n\nAssume you have a xlsx file like below:\n\n| ID  | NameOf | Age | Slice      | UnmarshalString |\n| --- | ------ | --- | ---------- | --------------- |\n| 1   | Andy   | 1   | 1\\|2       | {\"Foo\":\"Andy\"}  |\n| 2   | Leo    | 2   | 2\\|3\\|4    | {\"Foo\":\"Leo\"}   |\n| 3   | Ben    | 3   | 3\\|4\\|5\\|6 | {\"Foo\":\"Ben\"}   |\n| 4   | Ming   | 4   | 1          | {\"Foo\":\"Ming\"}  |\n\n+ the first row is the title row.\n+ other row is the data row.\n\n\u003e All examples list in [https://godoc.org/github.com/szyhf/go-excel#pkg-examples](https://godoc.org/github.com/szyhf/go-excel#pkg-examples).\n\n```go\n// defined a struct\ntype Standard struct {\n\t// use field name as default column name\n\tID      int\n\t// column means to map the column name\n\tName    string `xlsx:\"column(NameOf)\"`\n\t// you can map a column into more than one field\n\tNamePtr *string `xlsx:\"column(NameOf)\"`\n\t// omit `column` if only want to map to column name, it's equal to `column(AgeOf)`\n\tAge     int     `xlsx:\"AgeOf\"`\n\t// split means to split the string into slice by the `|`\n\tSlice   []int `xlsx:\"split(|)\"`\n\t// *Temp implement the `encoding.BinaryUnmarshaler`\n\tTemp    *Temp `xlsx:\"column(UnmarshalString)\"`\n\t// support default encoding of json\n\tTempEncoding *TempEncoding `xlsx:\"column(UnmarshalString);encoding(json)\"`\n\t// use '-' to ignore.\n\tIgnored string `xlsx:\"-\"`\n}\n\n// func (this Standard) GetXLSXSheetName() string {\n// \treturn \"Some other sheet name if need\"\n// }\n\ntype Temp struct {\n\tFoo string\n}\n\n// self define a unmarshal interface to unmarshal string.\nfunc (this *Temp) UnmarshalBinary(d []byte) error {\n\treturn json.Unmarshal(d, this)\n}\n\nfunc simpleUsage() {\n\t// will assume the sheet name as \"Standard\" from the struct name.\n\tvar stdList []Standard\n\terr := excel.UnmarshalXLSX(\"./testdata/simple.xlsx\", \u0026stdList)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc defaultUsage(){\n\tconn := excel.NewConnecter()\n\terr := conn.Open(\"./testdata/simple.xlsx\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer conn.Close()\n\n\t// Generate an new reader of a sheet\n\t// sheetNamer: if sheetNamer is string, will use sheet as sheet name.\n\t//             if sheetNamer is int, will i'th sheet in the workbook, be careful the hidden sheet is counted. i ∈ [1,+inf]\n\t//             if sheetNamer is a object implements `GetXLSXSheetName()string`, the return value will be used.\n\t//             otherwise, will use sheetNamer as struct and reflect for it's name.\n\t// \t\t\t   if sheetNamer is a slice, the type of element will be used to infer like before.\n\trd, err := conn.NewReader(stdSheetName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer rd.Close()\n\n\tfor rd.Next() {\n\t\tvar s Standard\n\t\t// Read a row into a struct.\n\t\terr:=rd.Read(\u0026s)\n\t\tif err!=nil{\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf(\"%+v\",s)\n\t}\n\n\t// Read all is also supported.\n\t// var stdList []Standard\n\t// err = rd.ReadAll(\u0026stdList)\n\t// if err != nil {\n\t//   panic(err)\n\t//\t return\n\t// }\n\t// fmt.Printf(\"%+v\",stdList)\n\n\t// map with string key is support, too.\n\t// if value is not string\n\t// will try to unmarshal to target type\n\t// but will skip if unmarshal failed.\n\n\t// var stdSliceList [][]string\n\t// err = rd.ReadAll(\u0026stdSliceList)\n\t// if err != nil {\n\t//   panic(err)\n\t//\t return\n\t// }\n\t// fmt.Printf(\"%+v\",stdSliceList)\n\n\t// var stdMapList []map[string]string\n\t// err = rd.ReadAll(\u0026stdMapList)\n\t// if err != nil {\n\t//   panic(err)\n\t//\t return\n\t// }\n\t// fmt.Printf(\"%+v\",stdMapList)\n\n\t// Using binary instead of file.\n\t// xlsxData, err := ioutil.ReadFile(filePath)\n\t// if err != nil {\n\t// \tlog.Println(err)\n\t// \treturn\n\t// }\n\n\t// conn := excel.NewConnecter()\n\t// err = conn.OpenBinary(xlsxData)\n}\n```\n\n\u003e See the `simple.xlsx`.`Standard` in `testdata` and code in `./standard_test.go` and `./standard_example_test.go` for details.\n\n\u003e While read into a `[]string`, row of title can have duplicated titles, otherwise `ErrDuplicatedTitles` will be return.\n\n## Advance | 进阶用法\n\nThe advance usage can make more options.\n\n### Config | 配置\n\nUsing a config as \"excel.Config\":\n\n```go\ntype Config struct {\n\t// sheet: if sheet is string, will use sheet as sheet name.\n\t//        if sheet is a object implements `GetXLSXSheetName()string`, the return value will be used.\n\t//        otherwise, will use sheet as struct and reflect for it's name.\n\t// \t\t  if sheet is a slice, the type of element will be used to infer like before.\n\tSheet interface{}\n\t// Use the index row as title, every row before title-row will be ignore, default is 0.\n\tTitleRowIndex int\n\t// Skip n row after title, default is 0 (not skip), empty row is not counted.\n\tSkip int\n\t// Auto prefix to sheet name.\n\tPrefix string\n\t// Auto suffix to sheet name.\n\tSuffix string\n}\n```\n\nTips:\n\n+ Empty row will be skipped.\n+ Column larger than len(TitleRow) will be skipped.\n+ Only empty cell can fill with default value, if a cell can not parse into a field it will return an error.\n+ Default value can be unmarshal by `encoding.BinaryUnmarshaler`, too.\n+ If no title row privoded, the default column name in exce like `'A', 'B', 'C', 'D' ......, 'XFC', 'XFD'` can be used as column name by 26-number-system.\n\nFor more details can see the code in `./test/advance_test.go` and file in `simple.xlsx`.`Advance.suffx` sheet.\n\n## XLSX Tag | 标签使用\n\n### column\n\nMap to field name in title row, by default will use the field name.\n\n### default\n\nSet default value when no value is filled in excel cell, by default is 0 or \"\".\n\n### split\n\nSplit a string and convert them to a slice, it won't work if not set.\n\n### nil\n\nWill not skip scan value in the cell equals to this 'nil value'\n\n### req\n\nWill return error if clomun title not exist in excel.\n\n### encoding\n\nWill decode the string value into the field can be unmarshal by the encoding type, currently, only `json` is supported, will use `encoding/json` package.\n\n## XLSX Field Config | 字段的解析配置\n\nSometimes it’s a bit cumbersome to deal with escape characters (exp. #6), so implement the interface of `GetXLSXFieldConfigs() map[string]FieldConfig` will take a high priority than `tag` to provide the field config, more info to see the test file.\n\n## RoadMap | 开发计划\n\n+ Read xlsx file and got the expect xml. √\n+ Prepare the shared string xml. √\n+ Get the correct sheetX.xml. √\n+ Read a row of a sheet. √\n+ Read a cell of a row, fix the empty cell. √\n+ Fill string cell with value of shared string xml. √\n+ Can set the column name row, default is the first row. √\n+ Read a row into a slice. √\n+ Read a row to a struct by column name. √\n+ Read a row into a map with string key. √\n+ Read a row into a map by primary key.\n\n## Thinking | 随想\n\n在复杂的系统中（例如游戏）\n\n有时候为了便于非专业人员设置一些配置\n\n会使用Excel作为一种轻量级的关系数据库或者配置文件\n\n毕竟对于很多非开发人员来说\n\n配个Excel要比写json或者yaml什么简单得多\n\n这种场景下\n\n读取特定格式（符合关系数据库特点的表格）的数据会比各种花式写入Excel的功能更重要\n\n毕竟从编辑上来说微软提供的Excel本身功能就非常强大了\n\n而现在我找到的Excel库的功能都过于强大了\n\n用起来有点浪费\n\n于是写了这个简化库\n\n这个库的工作参考了[tealeg/xlsx](https://github.com/tealeg/xlsx)的部分实现和读取逻辑。\n\n感谢[tealeg](https://github.com/tealeg)\n","funding_links":[],"categories":["Microsoft Office","微软办公软件","Utilities","Go","Microsoft Excel","工具库","实用工具"],"sub_categories":["Microsoft Excel","EXCEL","交流","Advanced Console UIs","HTTP Clients"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszyhf%2Fgo-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszyhf%2Fgo-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszyhf%2Fgo-excel/lists"}