如何通过代码创建标准的“Microsoft Excel”按钮?

问题描述

我想知道如何通过代码创建标准按钮“Microsoft Excel”,我所指的按钮是创建的:

打开页面,右键单击功能区、自定义功能区、Microsoft Dynamics 365 Business Central、打印发送并“添加”“Microsoft Excel”以在功能页面上执行您想要的操作。

我知道我可以使用 excel 缓冲区或代码单元,但我希望在“Microsoft Excel”中使用的功能可以通过代码创建按钮,我想要一些东西:

“CU 365 Excel”.createExcelByTable(18)。

提前致谢。

解决方法

您所指的按钮是平台的一部分。不能通过代码添加。

不过我认为您可以通过使用 Excel BufferRecordRefFieldRef 和系统表 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;