Hello,
I have the libXL library which has a windows DLL.
How would I write a wrapper for PureBasic for this?
I have the documentation from the web site like:
int xlBookLoad(BookHandle handle, const wchar_t* filename)
So, "simply" prototype it as given as example in PureBasic help and map the types accordingly?
Is that correct so far? What needs also to be checked before?
Thanks a lot in advance,
regards!
libXL; PB wrapper how to do?
Re: libXL; PB wrapper how to do?
This worked for me
Code:
Code:
Code: Select all
;Tested with PureBasic 7.51b (x64)
EnableExplicit
ImportC "libxl.lib"
xlCreateBookW.i()
xlBookReleaseW.i(book.i)
xlBookAddSheetW.i(book.i,sheet.s,flag.i)
xlSheetWriteStrW.i(sheet.i,x.i,y.i,string.s,flag.i)
xlSheetWriteNumW.i(sheet.i,x.i,y.i,value.i,flag.i)
xlBookSaveW.i(book.i,save.s)
;...
EndImport
Global book.i
Global sheet.i
book = xlCreateBookW()
If book
sheet = xlBookAddSheetW(book,"sheet1",#Null)
If sheet
xlSheetWriteStrW(sheet,2,2,"Hello World!",#Null)
xlSheetWriteNumW(sheet,3,1,1000,#Null)
xlBookSaveW(book,"test.xls")
EndIf
xlBookReleaseW(book)
EndIf
End
Re: libXL; PB wrapper how to do?
As easy as expected...
Using the DLL directly should also work.
Thanks a lot for the example!!!
Using the DLL directly should also work.
Thanks a lot for the example!!!
Re: libXL; PB wrapper how to do?
Confirm this works here, too.Mijikai wrote:This worked for me ]
But just tried to load and modify a file; this does not work..
Do you have an idea ? TIA..ImportC "libxl.lib"
xlCreateBookW.i()
xlBookReleaseW.i(book.i)
xlBookAddSheetW.i(book.i,sheet.s,flag.i)
xlSheetWriteStrW.i(sheet.i,x.i,y.i,string.s,flag.i)
xlSheetWriteNumW.i(sheet.i,x.i,y.i,value.i,flag.i)
xlBookSaveW.i(book.i,save.s)
xlBookLoadW(book.i,filename.s, tempfile.s)
EndImport
Global book.i
Global sheet.i
Define bret.i
book = xlCreateBookW()
If book
sheet = xlBookAddSheetW(book,"sheet1",#Null)
If sheet
xlSheetWriteStrW(sheet,2,2,"Hello World!",#Null)
xlSheetWriteNumW(sheet,3,1,1000,#Null)
xlBookSaveW(book,"test.xls")
EndIf
xlBookReleaseW(book)
EndIf
book = xlCreateBookW()
If book
bret=xlBookLoadW(book,"test.xls","")
Debug bret
sheet = xlBookAddSheetW(book,"sheet2","") ;- <-- Always stops with IMA error
If sheet
xlSheetWriteStrW(sheet,2,2,"Hello World!",#Null)
xlSheetWriteNumW(sheet,3,1,1000,#Null)
xlBookSaveW(book,"test2.xls")
EndIf
xlBookReleaseW(book)
EndIf
End
Re: libXL; PB wrapper how to do?
Probably because of the empty string.
Try:
Also you create a book instead of using the loaded book.
Use:
Try:
Code: Select all
sheet = xlBookAddSheetW(book,"sheet2",#Null)
Use:
Code: Select all
sheet = xlBookAddSheetW(bret,"sheet2",#Null)