aswjh / excel Goto Github PK
View Code? Open in Web Editor NEWread and write excel files in go/golang
License: BSD 2-Clause "Simplified" License
read and write excel files in go/golang
License: BSD 2-Clause "Simplified" License
I open the 'excel.xls' file manually.
Then use Go to do some operation and then call 'xl.SaveAs("excel.xls") '.
The return code is OK.
But it can not write back correctly.
How to solve this problem?
I want to get current Used Rows, is there any method?
Microsoft Excel 不能使用对象链接和嵌入的错误
Hi it looks like mattn/go-ole is no more, and the import needs to be go-ole/go-ole, otherwise i get errors.
I was use python to implement like, is there any method could do the same in golang?
Excel.ScreenUpdating = False
Excel.Calculation=-4135 # manual
.... long job
Excel.ScreenUpdating = True
Excel.Calculation=-4105 # auto
SaveAs should return err
I am confused of using this lib to open a *.xls file, because it returns @Open:
when I call the Open() func.
func process(file string) (err error) {
option := excel.Option{"Visible": true, "DisplayAlerts": true}
mso, err := excel.Open(file, option)
if err != nil {
log.Printf("open excel error: %v\n", err)
return
}
fmt.Println(mso.Version)
fmt.Println(mso.FILEFORMAT)
return
}
Output is :
2016/10/09 09:51:15 open excel error: @Open:
So, any idea of adding some demo codes in README.md to show how to open an excel file?
Hi hope all is well.
When i try to read a cell that is formatted as "Currency" i got nothing.
In the end i added this to the excel.String function (copied excel.String modfied the copy)
case excel.VARIANT:
if val.(excel.VARIANT).VT == ole.VT_CY {
_val := *((*int64)(unsafe.Pointer(&val.(excel.VARIANT).Val)))
ret = strconv.FormatFloat(float64(_val)*float64(0.0001), 'f', -1, 64)
}
There is probably a better way of doing this. Just want to let you know.
没有一个文档吗???
r := oleutil.MustGetProperty(sheet.Range("B3:D10").Idisp,"Value").ToArray()
//println(r)
//
for ka, va := range r.ToValueArray() {
fmt.Printf("key[%s] value[%s]\n", ka, va)
}
got Nil values
just run the sample code, with a simple xlsx
func main() {
option := excel.Option{"Visible": true, "DisplayAlerts": true}
//xl, _ := excel.New(option) //
xl, _ := excel.Open("old.xlsx", option)
defer xl.Quit()
sheet, _ := xl.Sheet(1) //xl.Sheet("sheet1")
sheet.Cells(1, 1, "hello")
sheet.PutCell(1, 2, 2006)
sheet.MustCells(1, 3, 3.14159)
println("str:"+sheet.MustCells(1, 2), sheet.MustGetCell(1, 2).(float64))
cell := sheet.MustCell(5, 6)
cell.Put("go")
cell.Put("font", map[string]interface{}{"name": "Arial", "size": 26, "bold": true})
cell.Put("interior", "colorindex", 6)
sheet.PutRange("a3:c3", []string {"@1", "@2", "@3"})
sheet.Range("d3:f3").Put([]string {"~4", "~5", "~6"})
time.Sleep(3000000000)
xl.SaveAs("test_excel.xls") //xl.SaveAs("test_excel", "html")
}
user@debian:~$ go get -v github.com/aswjh/excel
github.com/aswjh/excel (download)
github.com/go-ole/go-ole (download)
github.com/go-ole/go-ole
github.com/go-ole/go-ole/oleutil
github.com/aswjh/excel
# github.com/aswjh/excel
go/src/github.com/aswjh/excel/excel.go:20:22: undefined: syscall.LoadDLL
go/src/github.com/aswjh/excel/excel.go:841:32: not enough arguments in call to convertHresultToError
go/src/github.com/aswjh/excel/excel.go:852:33: not enough arguments in call to convertHresultToError
system: debian 9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.