Here is spreadsheet version of the venerable Hello World program illustrating an extremely simple but working example. Note that since the example uses only one workbook and one sheet, there is no need to deal with handles for them. And to maximize simplicity, we use the default font and format, so there is no need for any of those handles either.
Program hello,1.0(100) ! hello world spreadsheet example
++include ashinc:ashell.def
++include libxl:libxl.bsi
call Fn'LibXL'Load(dlflags=DLF_STATUS_BASERR or DLF_SYSERR_BASERR)
if Fn'LibXL'CreateBook() then
if Fn'LibXL'AddSheet("Sheet1") then
call Fn'LibXL'Write(1, 1, “Hello World”)
endif
call Fn'LibXL'SaveBook(“hello.xls”)
call LibXL'ReleaseBook()
endif
call Fn'LibXL'Unload()
The program loads the LibXL library, creates an empty book, adds a sheet to it, writes “Hello World” into the first column of the second row (using 0 based counting), then saves the book to the file hello.xls. Finally it cleans up by releasing the resources associated with the book and unloading the library. It doesn’t launch the spreadsheet application but you could do so with MX_SHELLEX or Fn’Shell’Exec() from sosfunc:fnshellex.bsi.