The underlying library is divided into these four classes, and for each class instance there is a corresponding handle that must be passed to the class functions. The handles are 32 bit raw address values (B,4 with deftype aliases defined in libxl.def) which must be treated with care, i.e. should never be manipulated directly in BASIC. Although nearly all the functions internally require the corresponding handle to the instance of the class, in many cases it is implicit and the library can supply the handle without the application's help. For example, once you create a workbook, from that point forward that book will be the default for any further operations that require a book handle, so the application doesn't need to redundantly specify it. But if you are working with two books, then you'll need to specify the proper book handle whenever switching the context from one to the other. Likewise for sheets, formats, and fonts. For all functions that take optional handle parameters, the handle parameter will come after the mandatory parameters, and may be specified by name using the standard handle parameter names "hbook", "hsheet", "hformat", "hfont", "hinitsheet", etc. So for example:
hBook1 = Fn'LibXL'CreateBook(type) | ! 1st book instance |
hBook2 = Fn'LibXL'CreateBook(type) | ! 2nd book instance |
! add sheet to 2nd book (default)
hSheet2A = Fn'LibXL'AddSheet("sheet1")
! add sheet to 1st book (explicit)
hSheet1A = Fn'LibXL'AddSheet("sheet1",hbook=hBook1)
When the handle is mandatory, it will be the first parameter.