Tuesday, 4 January 2022

How to export data using excel buffer in Business Central Sandbox for all the available companies

Hello guys, 

Happy new year to everyone, so in this blog I'm going to discuss about exporting data using excel buffer for all the available companies.

questions that would arise is answered below-

Why we need excel buffer to export when we have built-in excel which exports record?

We use excel buffer in Business central only when we need to handle a special situations like, 

to export all the data from all the available companies, 

export data for different languages ex. french, german or arabic or any other.


So, long story short I'll let you know what I did to export G/L Account in sandbox.

Create  a codeunit and a page. Page for a button click and codeunit to do your export processing.

Step 1: Create a new codeunit with a procedure to do your excel export for all the companies.

We need a temp excel buffer to store the data,

Use NewRow to create new rows in excel.

use addcolumn function to add new columns, do the data assignments and create a new excel write into sheet and close the book. 

The below code can be used to perform your actions.


Step 3: Create a new page with an action button which points to the procedure of your newly created codeunit.


Step 4: Publish the extension and verify the exported records.