I am trying to use Powerbuilder 2019 R2 to load the Office Interop .NET assembly so that I can format an existing Excel spreadsheet. I have found some C# code that opens Excel and then instantiates the Excel Workbook by opening a file using the Excel Application class. I am trying to duplicate that process in Powerbuilder.
I used the .NET DLL Importer and it created NVOs for the Application , Workbook, and Worksheet Classes from Microsoft.Office.Interop.Excell.dll.
The Powerbuilder code below works and opens an EXCEL process.
Powerbuilder Code:
nvo_applicationclass lnvo_app
nvo_workbookclass lnvo_wb
nvo_worksheetclass lnvo_ws
dotnetassembly lcs_ass_excel
long li_return
string ls_text
lcs_ass_excel = CREATE dotnetassembly
lnvo_app = CREATE nvo_applicationclass
lnvo_wb = CREATE nvo_workbookclass
lnvo_ws = CREATE nvo_worksheetclass
li_return = lcs_ass_excel.LoadWithDotNetFramework("microsoft.office.interop.excel.dll")
if li_return < 0 then
messagebox('Load .NET Failed', lcs_ass_excel.ErrorText)
return
end if
li_return = lcs_ass_excel.CreateInstance ("microsoft.office.interop.excel.ApplicationClass", lnvo_app)
The next step would be to Open the XLSX file and instantiate the Workbook- similar to this C#code:
Excel.Application MyApp = new Excel.Application();
Excel.Workbook myWorkbook = MyApp.Workbooks.Open(FilePath,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing);
Is this possible using the .NET tools in Powerbuilder 2019 R2?
Peter
Thank you for your thorough explanation. This was very helpful.
Peter