Please enable JavaScript to view this site.

Altova® EBA add-in for Excel, version 2022 Enterprise Edition

Each of the C# code listings illustrated below represents the Program.cs file in a standard .NET Framework console application. Before attempting to run the program code, make sure that you have added the required assembly references to the Visual Studio project, as described in Access API.

 

Export XBRL from Excel

The code listing below shows how to create a new Excel workbook using a specific XBRL entry point, populate a few properties and data cells, and save data to an XBRL file on the disk. The code will help you save both the Excel workbook and the XBRL file to the C:\XBRL_Examples directory.

 

using System;
using Excel = Microsoft.Office.Interop.Excel;
 
namespace EbaAddinClient
{
   class Program
   {
       static void Main(string[] args)
       {
           var app = new Excel.Application();
 
           try
           {
               // Suppress Excel alerts and create a new workbook
               Console.WriteLine("Creating a new workbook...");
               app.DisplayAlerts = false;
               var wb = (Excel._Workbook)(app.Workbooks.Add());
 
               // Get the Automation API object
               Console.WriteLine("Getting the COM automation object...");
               dynamic addIn = app.COMAddIns.Item("Altova.EBAAddIn");
               dynamic automationObject = addIn.Object;
 
               // Create a new report using taxonomy entry point
               Console.WriteLine("Creating the new report...");
               automationObject.InsertNewReport("http://www.eba.europa.eu/eu/fr/xbrl/crr/fws/fp/gl-2019-05/2020-02-29/mod/fp_con.xsd");
 
               // Set the report properties
               Console.WriteLine("Setting the report properties...");
               var rp = automationObject.GetReportProperties(wb);
               rp.ReportingEntityScheme = "http://standards.iso.org/iso/17442";
               rp.ReportingEntityIdentifier = "123456";
 
               // Find table by its code and ensure it is included in this report
               var tab = automationObject.GetTableTree(wb);
               var tableNode = tab.FindTableByRCCode("P 00.01");
               tableNode.IncludeInFiling = true;
 
               // Populate cells
               Console.WriteLine("Populating cells...");
               tableNode.Forms.Item(0).DataRange.Item(1).Value = "National GAAP";
               tableNode.Forms.Item(0).DataRange.Item(2).Value = "Consolidated";
 
               // Export data to XBRL
               Console.WriteLine("Exporting the XBRL instance...");
               automationObject.ExportXBRL(wb, @"C:\XBRL_Examples\Example.xbrl");
 
               // Save and close the .xlsx workbook
               Console.WriteLine("Saving the .xlsx file...");
               wb.SaveAs(@"C:\XBRL_Examples\Example.xlsx");
               wb.Close();
 
               Console.WriteLine("Task completed.");                
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);              
           }
           finally
           {
               app.DisplayAlerts = true;
               app.Quit();
           }
       }
   }
}

 

Import XBRL to Excel

The code listing below shows how to convert an XBRL file to an Excel file. To run this example successfully, an XBRL instance file must exist at C:\XBRL_Examples\Example.xbrl. Otherwise, change the path accordingly. Use the Export command to create an XBRL file by running the previous code listing or manually from Excel. For more information, see Export Data to XBRL.

 

using System;
using Excel = Microsoft.Office.Interop.Excel;
 
namespace ConsoleApp1
{
   class Program
   {
       static void Main(string[] args)
       {
           var app = new Excel.Application();
           try
           {
               // Suppress Excel alerts and create a new workbook
               Console.WriteLine("Creating a new workbook...");
               app.DisplayAlerts = false;
               var wb = (Excel._Workbook)(app.Workbooks.Add());
 
               // Get the Automation API object
               Console.WriteLine("Getting the COM automation object...");
               dynamic addIn = app.COMAddIns.Item("Altova.EBAAddIn");
               dynamic automationObject = addIn.Object;
 
               // Import EBA report eba_example.xbrl
               Console.WriteLine("Importing XBRL...");
               automationObject.ImportXBRL(@"C:\XBRL_Examples\Example.xbrl");
 
               // Save as xlsx
               Console.WriteLine("Saving the .xlsx file...");
               wb.SaveAs(@"C:\XBRL_Examples\Example.xlsx");
               wb.Close();
 
               Console.WriteLine("Task complete.");
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);
           }
           finally
           {
               app.DisplayAlerts = true;
               app.Quit();
           }
       }
   }
}

 

© 2015-2021 Altova GmbH