{"id":13756280,"url":"https://github.com/aswjh/excel","last_synced_at":"2025-05-10T03:31:20.348Z","repository":{"id":20994812,"uuid":"24284378","full_name":"aswjh/excel","owner":"aswjh","description":"read and write excel files in go/golang","archived":false,"fork":false,"pushed_at":"2019-03-02T03:15:59.000Z","size":59,"stargazers_count":84,"open_issues_count":0,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T11:01:52.750Z","etag":null,"topics":["excel","go","golang","ole"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aswjh.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}},"created_at":"2014-09-21T06:52:32.000Z","updated_at":"2024-04-19T06:58:05.000Z","dependencies_parsed_at":"2022-08-08T04:00:07.616Z","dependency_job_id":null,"html_url":"https://github.com/aswjh/excel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aswjh%2Fexcel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aswjh%2Fexcel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aswjh%2Fexcel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aswjh%2Fexcel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aswjh","download_url":"https://codeload.github.com/aswjh/excel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224911429,"owners_count":17390840,"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","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","golang","ole"],"created_at":"2024-08-03T11:00:40.592Z","updated_at":"2024-11-16T11:31:25.700Z","avatar_url":"https://github.com/aswjh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"﻿# excel for golang\n\nread and write excel files in golang.\n\ngo语言读写excel文件.\n\n# dependency\n\n[github.com/go-ole/go-ole][ole]\n\n# install\n\ngo get github.com/aswjh/excel\n\n# example\n``` go\npackage main\n\nimport (\n\t\"runtime\"\n\t\"fmt\"\n\t\"time\"\n\t\"github.com/aswjh/excel\"\n)\n\nfunc main() {\n\truntime.GOMAXPROCS(1)\n\toption := excel.Option{\"Visible\": true, \"DisplayAlerts\": true, \"ScreenUpdating\": true}\n\txl, _ := excel.New(option)      //xl, _ := excel.Open(\"test_excel.xls\", option)\n\tdefer xl.Quit()\n\n\tsheet, _ := xl.Sheet(1)         //xl.Sheet(\"sheet1\")\n\tdefer sheet.Release()\n\tsheet.Cells(1, 1, \"hello\")\n\tsheet.PutCell(1, 2, 2006)\n\tsheet.MustCells(1, 3, 3.14159)\n\n\tcell := sheet.Cell(5, 6)\n\tdefer cell.Release()\n\tcell.Put(\"go\")\n\tcell.Put(\"font\", map[string]interface{}{\"name\": \"Arial\", \"size\": 26, \"bold\": true})\n\tcell.Put(\"interior\", \"colorindex\", 6)\n\n\tsheet.PutRange(\"a3:c3\", []string {\"@1\", \"@2\", \"@3\"})\n\trg := sheet.Range(\"d3:f3\")\n\tdefer rg.Release()\n\trg.Put([]string {\"~4\", \"~5\", \"~6\"})\n\n\turc := sheet.MustGet(\"UsedRange\", \"Rows\", \"Count\").(int32)\n\tprintln(\"str:\"+sheet.MustCells(1, 2), sheet.MustGetCell(1, 2).(float64), cell.MustGet().(string), urc)\n\n\tcnt := 0\n\tsheet.ReadRow(\"A\", 1, \"F\", 9, func(row []interface{}) (rc int) {    //\"A\", 1 or 1, 9 or 1 or nothing\n\t\tcnt ++\n\t\tfmt.Println(cnt, row)\n\t\treturn                                                                   //-1: break\n\t})\n\n\ttime.Sleep(2000000000)\n\n\t//Sort\n\tcells := excel.GetIDispatch(sheet, \"Cells\")\n\tcells.CallMethod(\"UnMerge\")\n\tsort := excel.GetIDispatch(sheet, \"Sort\")\n\tsortfields := excel.GetIDispatch(sort, \"SortFields\")\n\tsortfields.CallMethod(\"Clear\")\n\tsortfields.CallMethod(\"Add\", sheet.Range(\"f:f\").IDispatch, 0, 2)\n\tsort.CallMethod(\"SetRange\", cells)\n\tsort.PutProperty(\"Header\", 1)\n\tsort.CallMethod(\"Apply\")\n\n\t//Chart\n\tshapes := excel.GetIDispatch(sheet, \"Shapes\")\n\t_chart, _ := shapes.CallMethod(\"AddChart\", 65)\n\tchart := _chart.ToIDispatch()\n\tchart.CallMethod(\"SetSourceData\", sheet.Range(\"a1:c3\").IDispatch)\n\n\t//AutoFilter\n\tcells.CallMethod(\"AutoFilter\")\n\texcel.Release(sortfields, sort, cells, chart, shapes)\n\n\ttime.Sleep(3000000000)\n\txl.SaveAs(\"test_excel.xls\")    //xl.SaveAs(\"test_excel\", \"html\")\n}\n\n```\n\n# license\n\nThe [BSD 3-Clause license][bsd]\n\n[ole]: http://github.com/go-ole/go-ole\n[bsd]: http://opensource.org/licenses/BSD-3-Clause\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faswjh%2Fexcel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faswjh%2Fexcel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faswjh%2Fexcel/lists"}