The result: 6077 functions, and all constants up to Office 12.
Source is 1.2MB so is recommended to create a PB Lib, but currently there is a bug in PB that prevents from doing it, you can try it with the file Excel.pb.
Github project:
https://github.com/omegakode/PBExcel
Excel Reference:
https://learn.microsoft.com/en-us/offic ... view/excel
Usage:
All objects are of type IDispatch. When you no longer need an object call Release() on it.
Boolean values are #VARIANT_TRUE / #VARIANT_FALSE
Single is PB float.
Double is PB double.
Function parameters with non VARIANT types are passed directly, otherwise are passed as pointer to VARIANT.
When a function returns a non VARIANT type is returned directly, otherwise you must supply a pointer to a VARIANT as the last paramenter ie *result.VARIANT.
Use the Excel_GetLastError() functions to retrieve error info.
See examples in the example folder. Of course you will need MS Excel installed.
Ecample to create a workbook:
Code: Select all
;ExcelWrite.pb
EnableExplicit
XIncludeFile "..\Excel.pb"
Procedure main()
Protected.IDispatch excel, workBooks, workBook, cellsRange
Protected.VARIANT vRowIndex, vColIndex, vCellRange, vStr, vBool, vNone, vLong
Protected.l iCol, iRow
Protected.s file
COM_Init()
COM_VarNone(@vNone)
;Create Excel application
excel = Excel_Application()
If excel = 0
Debug "Error failed to create Excel application"
ProcedureReturn
EndIf
Excel_Application_Put_Visible(excel, #VARIANT_TRUE)
Excel_Application_Put_DisplayAlerts(excel, #VARIANT_FALSE)
;Add a workbook
workBooks = Excel_Application_Get_Workbooks(excel)
workBook = Excel_Workbooks_Add(workBooks, @vNone)
;Fill 2 rows of 10 columns
cellsRange = Excel_Application_Get_Cells(excel)
For iRow = 1 To 2
For iCol = 1 To 10
Excel_Range_Get_Item(cellsRange, COM_VarLong(@vRowIndex, iRow), COM_VarLong(@vColIndex, iCol), @vCellRange)
If vCellRange\pdispVal = 0 ;Error
Continue
EndIf
Excel_Range_Put_Value2(vCellRange\pdispVal, COM_VarString(@vStr, "Item" + Str(iRow) + "-" + Str(iCol)))
COM_VarClear(@vStr)
COM_VarClear(@vCellRange) ; = vCellRange\pdispVal\Release()
Next
Next
file = SaveFileRequester("Save", "", "", 0)
If file
Excel_Workbook_SaveAs(workBook, COM_VarString(@vStr, file), @vNone, @vNone, @vNone, @vNone, @vNone,
#xlNoChange, @vNone, @vNone, @vNone, @vNone, @vNone)
COM_VarClear(@vstr)
If Excel_GetLastError() <> 0
Debug "Failed to save file:"
Debug Excel_GetLastErrorDescription()
Else
Debug "File " + file + " saved succesfully"
EndIf
EndIf
Excel_Workbook_Close(workBook, COM_VarBool(@vBool, #VARIANT_FALSE), @vNone, @vNone)
workBook\Release()
workBooks\Release()
cellsRange\Release()
Excel_Application_Quit(excel)
excel\Release()
EndProcedure
main()