Function GemBoxSample(Void)

$insert LOGICAL
$insert REVDOTNETEQUATES

Declare function    Reactor_Services
Declare subroutine  Reactor_Services
Debug
* StartDate   = Iconv('11/17/2017', 'D')
* EndDate     = Iconv('11/21/2017', 'D')
* For ScheduleDate = StartDate to EndDate
*    rv  = Reactor_Services('ClearWafersProcessed', ScheduleDate)
*    rv  = Reactor_Services('UpdatePerformanceTrackers', ScheduleDate)
* Next ScheduleDate
* 
* Return


// Start the .NET engine.
hDotNet             = StartDotNet('')
Status              = Get_Status(StatusCode)

// Load a .NET assembly. This creates the system object (hDotNet).
rv                  = Set_Property.Net(hDotNet, 'AssemblyName', 'C:\Program Files (x86)\GemBox Software\GemBox.Spreadsheet 3.9\Bin\NET3X4X\GemBox.Spreadsheet.dll')
Status              = Get_Status(StatusCode)

// Create a Spreadsheet handle/class directly from the system object. This is necessary to activate the product license.
hSpreadsheetInfo    = Create_Class.Net(hDotNet, 'GemBox.Spreadsheet.SpreadsheetInfo', 0)
Status              = Get_Status(StatusCode)

// Set the product license.
rv                  = Send_Message.Net(hSpreadsheetInfo, 'SetLicense', 'EUZ6-PWUP-BDWC-VA5A')
Status              = Get_Status(StatusCode)

// Create an Excel file handle/class directly from the system object. This will be the primary object used.
hExcelFileFactory   = Create_Class.Net(hDotNet, 'GemBox.Spreadsheet.ExcelFile', 0)
Status              = Get_Status(StatusCode)

* hLoadOptions        = Create_Class.Net(hDotNet, 'GemBox.Spreadsheet.LoadOptions', 0)
* Status              = Get_Status(StatusCode)
* hXlsxDefault        = Get_Property.Net(hLoadOptions, 'XlsxDefault', 1)
* Status              = Get_Status(StatusCode)

// Load a worksheet from a specific path. This does not generate a handle/class. It just loads into the ExcelFile object the content of an actual Excel file.
* rv                  = Send_Message.Net(hExcelFile, 'Load', 'E:\apps\Scheduler\Daily (Template).xlsx' : @FM : hXlsxDefault, 'System.String' : @FM : 'GemBox.Spreadsheet.LoadOptions')
* hExcelFile          = Send_Message.Net(hExcelFileFactory, 'Load', 'E:\apps\Scheduler\Daily (Template).xlsx' : @FM : hXlsxDefault, 'System.String' : @FM : 'GemBox.Spreadsheet.LoadOptions', 1)
hExcelFile          = Send_Message.Net(hExcelFileFactory, 'Load', 'E:\apps\Scheduler\Daily (Template).xlsx', 'System.String', 1)
Status              = Get_Status(StatusCode)
* Debug
// Create a Worksheet collection handle/class from the Worksheets property of the ExcelFile class.
hWorksheets         = Get_Property.Net(hExcelFile, 'Worksheets', 1)
Status              = Get_Status(StatusCode)
* rv                  = Send_Message.Net(hWorksheets, 'Add', 'MySheet')
* Status              = Get_Status(StatusCode)
WorkSheetCount      = Get_Property.Net(hWorksheets, 'Count')
Status              = Get_Status(StatusCode)
Debug
hActiveWorksheet    = Get_Property.Net(hWorksheets, 'Item[2]', 1)
Status              = Get_Status(StatusCode)
hRows               = Get_Property.Net(hActiveWorksheet, 'Rows', 1)
Status              = Get_Status(StatusCode)
RowCount            = Get_Property.Net(hRows, 'Count')
Status              = Get_Status(StatusCode)
hColumns            = Get_Property.Net(hActiveWorksheet, 'Columns', 1)
Status              = Get_Status(StatusCode)
ColumnCount         = Get_Property.Net(hColumns, 'Count')
Status              = Get_Status(StatusCode)
hActiveRow          = Get_Property.Net(hRows, 'Item[1]', 1)
Status              = Get_Status(StatusCode)
hCells              = Get_Property.Net(hActiveRow, 'Cells', 1)
Status              = Get_Status(StatusCode)
hActiveCell         = Get_Property.Net(hCells, 'Item[1]', 1)
Status              = Get_Status(StatusCode)
LastColumnIndex     = Get_Property.Net(hCells, 'LastColumnIndex')
Status              = Get_Status(StatusCode)
ColumnWidth         = Get_Property.Net(hCells, 'Width')
Status              = Get_Status(StatusCode)
CellValue           = Get_Property.Net(hActiveCell, 'Value')
Status              = Get_Status(StatusCode)
rv                  = Set_Property.Net(hActiveCell, 'Value', 25)
Status              = Get_Status(StatusCode)
* hActiveWorksheet    = Get_Property.Net(hWorksheets, 'ActiveWorksheet', 1)
* Status              = Get_Status(StatusCode)
* WorksheetName       = Get_Property.Net(hActiveWorksheet, 'Name')
WorksheetName       = Get_Property.Net(hActiveWorksheet, 'Name')
Status              = Get_Status(StatusCode)
* Methods             = Get_Info.Net(hActiveWorksheet, REVDOTNET_INFO_METHODS)
* Status              = Get_Status(StatusCode)
* Properties          = Get_Info.Net(hActiveWorksheet, REVDOTNET_INFO_PROPERTIES)
* Status              = Get_Status(StatusCode)


* Debug
rv                  = Send_Message.Net(hWorksheets, 'Add', 'Hello World')
Status              = Get_Status(StatusCode)
rv                  = Send_Message.Net(hExcelFile, 'Save', 'E:\apps\Scheduler\Hello World.xlsx')
Status              = Get_Status(StatusCode)

// Free all 
Free_Class.Net()

*        Dim ef As ExcelFile = New ExcelFile
*        Dim ws As ExcelWorksheet = ef.Worksheets.Add("Hello World")
* 
*        ws.Cells(0, 0).Value = "English:"
*        ws.Cells(0, 1).Value = "Hello"
* 
*        ws.Cells(1, 0).Value = "Russian:"
*        ' Using UNICODE string.
*        ws.Cells(1, 1).Value = New String(New Char() {ChrW(&H417), ChrW(&H434), ChrW(&H440), ChrW(&H430), ChrW(&H432), ChrW(&H441), ChrW(&H442), ChrW(&H432), ChrW(&H443), ChrW(&H439), ChrW(&H442), ChrW(&H435)})
* 
*        ws.Cells(2, 0).Value = "Chinese:"
*        ' Using UNICODE string.
*        ws.Cells(2, 1).Value = New String(New Char() {ChrW(&H4F60), ChrW(&H597D)})
* 
*        ws.Cells(4, 0).Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC."
*        ws.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = True
* 
*        ef.Save("Hello World.xlsx")
*

Return ''


UnusedCode:
*    hLoadOptions        = Create_Class.Net(hDotNet, 'GemBox.Spreadsheet.LoadOptions', 0)
*    Status              = Get_Status(StatusCode)
*    XlsxDefault         = Get_Property.Net(hLoadOptions, 'XlsxDefault', 0)
*    Status              = Get_Status(StatusCode)
*    Methods             = Get_Info.Net(hWorksheets, REVDOTNET_INFO_METHODS)
*    Status              = Get_Status(StatusCode)
*    Properties          = Get_Info.Net(hWorksheets, REVDOTNET_INFO_PROPERTIES)
*    Status              = Get_Status(StatusCode)
return

