-1

i want to know how create standard button "Microsoft Excel" by code, the button I'm referring to is created:

Open page, right click on Ribbon, Customize Ribbon, Microsoft Dynamics 365 Business Central, Print Send and "Add" "Microsoft Excel" to action what u want on ribbon page.

i know i can use excel buffer or code unit, but i want t he functionally what use at "Microsoft Excel" to create button by code, i would like something:

"CU 365 Excel".createExcelByTable(18).

Thanks in advance.

Tabutnas
  • 35
  • 6

1 Answers1

1

The button you are refering to is part of the platform. You can't add it by code.

I think however you can get very close by using a combination of the Excel Buffer, RecordRef, FieldRef and the system table Field:

procedure ExportTable(TableNo: Integer)
var
    Field: Record Field;
    RecRef: RecordRef;
    FldRef: FieldRef;
begin
    RecRef.Open(TableNo);

    if RecRef.FindSet() then
        repeat
            Field.SetRange(TableNo, RecRef.Number);
            // Add filters to filter out FlowFilters, Blobs etc.

            if Field.FindSet() then
                repeat
                    FldRef := RecRef.Field(Field."No.");
                    // Write FldRef.Value to ExcelBuffer
                until Field.Next() = 0;
        until RecRef.Next() = 0;

    // Export the Excel file
end;
kaspermoerch
  • 16,127
  • 4
  • 44
  • 67