Please wait
Talk to Expert
Microsoft Dynamics 365, Microsoft Dynamics Business central, Microsoft Dynamics NAV

Export to Excel Data Using Report in Dynamics 365 Business Central.

Picture7

In Dynamics 365 Business Central, you can export data to Excel using reports. This feature allows users to generate customized reports and export them directly to Excel for further analysis, sharing, or presentation.

Let start with Export to Excel Data Using Report!

Introduction:

Exporting data to Excel using a report in Microsoft Dynamics 365 Business Central can be achieved by creating a custom AL report that includes the required data and then configuring the report to export to Excel.

Here’s a step-by-step guide to help you accomplish this:

Step 1:- Open visual studio code  & Create your new project by setting Launch.json.

Step 2:- Download Symbols

Press F1 and Select download symbols after download symbols.

Step 3:- Create New AL file for report object & Open newly created file.

Step 4:- Create TReport Structure to build a new report for Export Data from BC to Excel file.

Step 5:- Add ID , Name & SourceExpressions.

And set the all report Property like Red marks value and extension name

 

Here is the Report All code:

report 50122 “New Customer”

{

UsageCategory = Administration;

ApplicationArea = All;

Caption = ‘Export Customer’;

 

dataset

{

dataitem(“Custom Customer”; “Custom Customer”)

{

trigger OnPreDataItem()

begin

MakeExcelDataHeader();

end;

 

trigger OnAfterGetRecord()

begin

if PrintExcel then

MakeExcelDataBody();

end;

 

}

 

}

 

requestpage

{

layout

{

area(Content)

{

group(GroupName)

{

field(Name; ”)

{

ApplicationArea = All;

 

}

}

}

}

 

actions

{

area(processing)

{

action(ActionName)

{

ApplicationArea = All;

 

}

}

}

}

trigger OnInitReport()

var

myInt: Integer;

begin

PrintExcel := true;

end;

 

trigger OnPreReport()

var

myInt: Integer;

begin

ExcelBuffer.DeleteAll;

end;

 

trigger OnPostReport()

var

myInt: Integer;

begin

if PrintExcel then

OpenExcelFile();

end;

 

var

ExcelBuffer: Record “Excel Buffer”;

PrintExcel: Boolean;

Text001: Text;

 

procedure MakeExcelInfo()

var

myInt: Integer;

begin

 

end;

 

procedure MakeExcelDataHeader()

var

myInt: Integer;

begin

ExcelBuffer.AddColumn(“Custom Customer”.FieldCaption(“No.”), False, ”, True, False, True, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.FieldCaption(Name), False, ”, True, False, True, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.FieldCaption(Address), False, ”, True, False, True, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.FieldCaption(Address2), False, ”, True, False, True, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.FieldCaption(City), False, ”, True, False, True, ”, ExcelBuffer.”Cell Type”::Text);

end;

 

procedure MakeExcelDataBody()

var

myInt: Integer;

begin

ExcelBuffer.NewRow();

ExcelBuffer.AddColumn(“Custom Customer”.”No.”, False, ”, false, False, false, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.Name, False, ”, False, False, false, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.Address, False, ”, false, False, false, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.Address2, False, ”, false, False, false, ”, ExcelBuffer.”Cell Type”::Text);

ExcelBuffer.AddColumn(“Custom Customer”.City, False, ”, false, False, false, ”, ExcelBuffer.”Cell Type”::Text);

end;

 

local procedure OpenExcelFile()

var

myInt: Integer;

begin

ExcelBuffer.CreateNewBook(‘Sales Order’);

ExcelBuffer.WriteSheet(‘Sales Order’, ”, ‘Summary’);

ExcelBuffer.CloseBook;

ExcelBuffer.OpenExcel;

end;}

Search your report to run & Export data to Excel file.

Click New Customer it’s a Customize Page:

Click On Action > Export Excel from New Customer Page:

Apply filter if you want to export only filtered records from Customer & Run your report.

Below is your exported Excel file with filtered customer data.

 

Thank you for investing your time to read our blog! We’re passionate about sharing valuable insights to help you navigate the world of Business Central.

If you’re curious about how we can assist you in reaching your goals, don’t hesitate to get in touch. Our dedicated team is ready to provide support every step of the way.

Let’s turn your vision into reality together!


Comments