github.com/remoteit/go-ole@v1.2.7/_example/excel/excel.go (about) 1 // +build windows 2 3 package main 4 5 import ( 6 "time" 7 8 ole "github.com/remoteit/go-ole" 9 "github.com/remoteit/go-ole/oleutil" 10 ) 11 12 func main() { 13 ole.CoInitialize(0) 14 unknown, _ := oleutil.CreateObject("Excel.Application") 15 excel, _ := unknown.QueryInterface(ole.IID_IDispatch) 16 oleutil.PutProperty(excel, "Visible", true) 17 workbooks := oleutil.MustGetProperty(excel, "Workbooks").ToIDispatch() 18 workbook := oleutil.MustCallMethod(workbooks, "Add", nil).ToIDispatch() 19 worksheet := oleutil.MustGetProperty(workbook, "Worksheets", 1).ToIDispatch() 20 cell := oleutil.MustGetProperty(worksheet, "Cells", 1, 1).ToIDispatch() 21 oleutil.PutProperty(cell, "Value", 12345) 22 23 time.Sleep(2000000000) 24 25 oleutil.PutProperty(workbook, "Saved", true) 26 oleutil.CallMethod(workbook, "Close", false) 27 oleutil.CallMethod(excel, "Quit") 28 excel.Release() 29 30 ole.CoUninitialize() 31 }