-
Notifications
You must be signed in to change notification settings - Fork 0
/
excel.go
31 lines (24 loc) · 941 Bytes
/
excel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build windows
package main
import (
"time"
ole "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil"
)
func main() {
ole.CoInitialize(0)
unknown, _ := oleutil.CreateObject("Excel.Application")
excel, _ := unknown.QueryInterface(ole.IID_IDispatch)
oleutil.PutProperty(excel, "Visible", true)
workbooks := oleutil.MustGetProperty(excel, "Workbooks").ToIDispatch()
workbook := oleutil.MustCallMethod(workbooks, "Add", nil).ToIDispatch()
worksheet := oleutil.MustGetProperty(workbook, "Worksheets", 1).ToIDispatch()
cell := oleutil.MustGetProperty(worksheet, "Cells", 1, 1).ToIDispatch()
oleutil.PutProperty(cell, "Value", 12345)
time.Sleep(2000000000)
oleutil.PutProperty(workbook, "Saved", true)
oleutil.CallMethod(workbook, "Close", false)
oleutil.CallMethod(excel, "Quit")
excel.Release()
ole.CoUninitialize()
}