Reputation: 39
I am trying to create an Excel document with information from the page using a customized button. The Excel document should be open and then it's up to the user to save it - Similarly as it is done with the Export to Excel button embedded in some of the Acumatica grids.
I read this article where something similar is requested. However, adding the object
new PX.Export.Excel.Core.Package()
fails as the library is not recognized. Maybe this was deprecated in the latest releases?
I created this console project
using Excel = Microsoft.Office.Interop.Excel;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var excelApp = new Excel.Application();
// Make the object visible.
excelApp.Visible = true; ;
// Create a new, empty workbook and add it to the collection returned
// by property Workbooks. The new workbook becomes the active workbook.
// Add has an optional parameter for specifying a praticular template.
// Because no argument is sent in this example, Add creates a new workbook.
excelApp.Workbooks.Add();
excelApp.Cells[1, "A"] = "SNO";
excelApp.Cells[2, "B"] = "A";
excelApp.Cells[2, "C"] = "1122";
Excel._Worksheet workSheet = (Excel.Worksheet)excelApp.ActiveSheet;
}
}
}
and works correctly. But in Acumatica I receive the following error
Retrieving the COM class factory for component with CLSID
{00024500-0000-0000-C000-000000000046} failed due to the
following error: 80070005 Access is denied.
(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Thanks.
Upvotes: 0
Views: 229
Reputation: 2340
You need to add reference of PX.Export.dll (from AcumaticaSite -> Bin folder) in your extension library to work with PX.Export.Excel.Core.Package()
.
Upvotes: 1