I'm investigating using a .Net Assembly that our C# based web app uses, within our PowerBuilder desktop app. I am getting the following message from the CreateInstance function:
Constructor on type 'OfficeOpenXml.ExcelPackage' not found.
This code is the vendor's simple Hello World example:
// var file = new FileInfo(@"c:\temp\myWorkbook.xlsx");
// using(var package = new ExcelPackage(file))
// {
// var sheet = package.Workbook.Worksheets.Add("My Sheet");
// sheet.Cells["A1"].Value = "Hello World!";
//
// // Save to file
// package.Save();
// }
I tried using the .Net Importer and regular script as seen below and got the same error. I got the classname from the generated object. I am passing the file name as an argument to CreateInstance just like the C# snippet does. What do I need to do differently?
DotNetAssembly ldn_Assembly
DotNetObject ldn_Package
Long ll_return
String ls_dllfile, ls_classname
ls_dllfile = "C:\PBSource\PB2021\EPPlus\EPPlus.dll"
ls_classname = "OfficeOpenXml.ExcelPackage"
ldn_Assembly = Create DotNetAssembly
ll_return = ldn_Assembly.LoadWithDotNetFrameWork(ls_dllfile)
If ll_return < 0 Then
Messagebox("Load Assembly Failed", ldn_assembly.ErrorText, StopSign!)
Return
End If
ldn_Package = Create DotNetObject
ll_return = ldn_Assembly.CreateInstance(ls_classname, ldn_Package, ls_dllfile)
If ll_return < 0 Then
Messagebox("Create Instance Failed", ldn_assembly.ErrorText, StopSign!)
Return
End If
Destroy ldn_Assembly
Destroy ldn_Package
https://www.epplussoftware.com/docs/5.8/api/OfficeOpenXml.ExcelPackage.html