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
We currently have quite a few Powerbuilder apps that use OLE Automation to do some sophisticated formatting of Excel worksheets. It appears that Microsoft does not support OLE Automation in any of the Click To Run versions of Office, so we are researching alternatives to OLE. One option is to go to a C# app/dll, but we were hoping to stay within Powerbuilder if that is possible.
Peter
So yes, to avoid the problems of incompatible type that Mark told you about, you would have to write a DLL which has compatible in and output parameters for powerbuilder and does the function calls to the other DLL with the incompatible types.
I'll ask our .net programmer tomorrow what problems he had with clickToRun office, maybe it's also important for what you are doing.
regards
So not really something to worry about.
regards