"Hello, World" Spreadsheet


Copy the code below into an Alpha Anywhere Xbasic script and run it. The code assumes that you have a version of Excel that can handle .XLSX files installed. If you have an older version of Excel, change ExcelDocument to Excel2003Document, and .xlsx to .xls. If you don't have Excel or a compatible spreadsheet program installed, remove the line that starts with sys_open.

'create the document (work book) to hold the sheet
dim Doc as Office::ExcelDocument

'create the sheet
dim Sheet as Office::Spreadsheet

'add the sheet to the document (work book) with a name
Sheet=Doc.AddSheet("Hello, World") 

'write a string to cell 2A (row 2, column 1) in the sheet
Sheet.Write(2,1,"Hello, World!") 

'write a number to cell 3A in the sheet

'save the document (work book) with the attached sheet

'delete all references to the document so that it can be read by Excel
delete Doc 

'launch Excel or any other registered handler for XLSX files on this work book

See Also