On 01/05/2017 11:52 AM, Mirko Vukovic wrote: > I apologize for this off-topic message, but I am hoping to find someone to > point me in the right direction. > > I want to write some code to read data from MS Excel files (not CSV > files). I saw the Apache POI project (Java).
Please consider using golang instead. Here's an example to read/write excel files without using COM: https://github.com/tealeg/xlsx package main import ( "fmt" "github.com/tealeg/xlsx" ) func main() { excelFileName := "/home/tealeg/foo.xlsx" xlFile, err := xlsx.OpenFile(excelFileName) if err != nil { ... } for _, sheet := range xlFile.Sheets { for _, row := range sheet.Rows { for _, cell := range row.Cells { text, _ := cell.String() fmt.Printf("%s\n", text) } } } } package main import ( "fmt" "github.com/tealeg/xlsx" ) func main() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell var err error file = xlsx.NewFile() sheet, err = file.AddSheet("Sheet1") if err != nil { fmt.Printf(err.Error()) } row = sheet.AddRow() cell = row.AddCell() cell.Value = "I am a cell!" err = file.Save("MyXLSXFile.xlsx") if err != nil { fmt.Printf(err.Error()) } } > > My goal is to access it via C (which I would from Common Lisp and the > foreign function interface & libffi). Naively, I am looking for a DLL that > I can hook into. Lastly, you might want to write something high-level very easily with golang, then expose it as a c shared/dll since it has the capacity to create dlls and expose C services now. http://blog.ralch.com/tutorial/golang-sharing-libraries/ Please note when you write your golang code, it's good for windows, macos and Linux. https://bitbucket.org/binet/go-ffi BUT the cgo tool helps to bring in anything based from c/c++. https://github.com/golang/go/wiki/cgo This tool is even higher level to automatically generate golang wrappers to c/c++: https://github.com/xlab/cgogen github.com/therecipe/qt would not exist if it weren't for xlab/cgogen. BTW I am clearly not a Lisp user, but lisp-related packages exist for golang if you look around. > > I can code rudimentary C, and wrote similar code to interface to National > Instrument's DLL's. > > Is such a goal even possible using the MSYS2 tool chain? > > I see that Microsoft has the COM, Net, and maybe other platforms, but still > don't understand how to use them nor find a simple Hello-world type example. Again if you really want to use COM in an easier way, without using MS .NET-based languages, then I suggest yet again golang. Here as another golang package that could accommodate you: https://github.com/go-ole/go-ole/blob/master/example/excel/excel.go package main import ( "time" ole "github.com/go-ole/go-ole" "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() } https://github.com/golang/go/wiki/WindowsDLLs > > My understanding of different compiler platforms (gcc vs MS) is next to > nil. If you reply, I may follow-up with questions for clarification. > > Thank you, > > Mirko > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > > > > _______________________________________________ > Msys2-users mailing list > Msys2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/msys2-users > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Msys2-users mailing list Msys2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/msys2-users