- Notifications
You must be signed in to change notification settings - Fork4
Goxcel is a library to operate MS Excel using go-ole library.
License
NotificationsYou must be signed in to change notification settings
devlights/goxcel
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Goxcel is a library to operate Excel usinggo-ole package. Thanksgo-ole package!
This library works only on Windows.
go get github.com/devlights/goxcel@latest
package mainimport ("github.com/devlights/goxcel")funcinit() {log.SetFlags(0)}// main is entry point of this app.funcmain() {ret,xlsx:=run()ifret==0 {// Launch EXCEL_=exec.Command("cmd","/C",xlsx).Run()}os.Exit(ret)}funcrun() (int,string) {// 0. Initialize Goxcelquit:=goxcel.MustInitGoxcel()deferquit()// 1. Create new Goxcel instance.excel,release:=goxcel.MustNewGoxcel()// must call goxcel release function when function exited// otherwise excel process was remained.deferrelease()// optional settingsvisible:=falseexcel.MustSilent(visible)// 2. Get Workbooks instance.wbs:=excel.MustWorkbooks()// 3. Add Workbookwb,wbRelease:=wbs.MustAdd()// call workbook's release functiondeferwbRelease()// 4. Get Worksheetws:=wb.MustSheets(1)// 5. Get Cellc:=ws.MustCells(1,1)// 6. Set the value to cellc.MustSetValue("こんにちはWorld")p:=filepath.Join(os.TempDir(),"helloworld.xlsx")log.Printf("SAVE FILE: %s\n",p)// 7. Savewb.MustSaveAs(p)// Workbook::SetSaved(true) and Workbook::Close() is automatically called when `defer wbReleaseFn()`.// Excel::Quit() and Excel::Release() is automatically called when `defer release()`.return0,p}
Also look at the "examples" directory :)
About
Goxcel is a library to operate MS Excel using go-ole library.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.