GLBasic forum

Main forum => GLBasic - en => Topic started by: Robert on 2015-Aug-28

Title: Libary call
Post by: Robert on 2015-Aug-28
I want to open an excelfile with a call to a function that is declared like this: DECLARE(ExcelOpen, DLL, (const char* szBook), int). I don't know C but I tried to place the excelfile in the same map as the app and just called with: XLS_Open("t.xlsx") but it doesn't work. Its a program in the Showroom/page 7/Excel interface.
Title: Re: Libary call
Post by: MrTAToad on 2015-Sep-03
Have you tried putting the excel file in the media directory ?
Title: Re: Libary call
Post by: Robert on 2015-Sep-04
Yes.
Code (glbasic) Select
XLS_Init(TRUE) // Yes, show excel

//XLS_NewWorkBook()

XLS_Open("t.xlsx")
XLS_SetActiveSheet(2)
XLS_SetCell(1,1, "5")
XLS_SetCell(1,2, "10")
XLS_SetCell(1,3, "=" + XLS_CellName$(1,1) + "+" + XLS_CellName$(1,2))

LOCAL string$
XLS_GetCell(1,3, string$)

STDOUT "reading: "+string$+"\n"


KEYWAIT

XLS_Quit()


Either it open a new file or, if I try to open on the first line, I get "NULL passed to autowrap"
Title: Re: Libary call
Post by: kanonet on 2015-Sep-04
Did you try an old .xls? I dont think that old code supports the more modern .xlsx, if it still runs at all...
Title: Re: Libary call
Post by: Robert on 2015-Sep-04
It can be so but I want to manipulate new files so install an old version is not an alternativ. Interesting though that it is possible to do.
Title: Re: Libary call
Post by: kanonet on 2015-Sep-04
New version of MS Office usually can also save to old file format. May be worth to at least try it.
Title: Re: Libary call
Post by: Robert on 2015-Sep-04
I tried saving as 2003 xls but can't get it to work. Think I give up, but thanks anyway.
Title: Re: Libary call
Post by: Qedo on 2015-Sep-06
work in:
c:\users\<your user name>\documents\t.xls

Ciao
Title: Re: Libary call
Post by: Robert on 2015-Sep-06
I tried to put that in as a string but i got syntax error. The compiler seems to not accept absolut adresses in a string.
Title: Re: Libary call
Post by: Qedo on 2015-Sep-06
Try:

address$="D:\\APPOGGIO\\Basic\\glbasic10\\code\\GLBasic\\Excel\\t.xls"

XLS_Open(address$)
Title: Re: Libary call
Post by: Robert on 2015-Sep-06
Thanks a lot, it works.

Strange that you can't put a single "\" in a string.
Title: Re: Libary call
Post by: Kitty Hello on 2015-Sep-07
The \ is an escape character. You have to \\ to escape a single \.