topic hubAL Developmentofficial - Microsoftreviewed - checked by Opus

Importing and exporting data

Importing and exporting data in AL covers XMLport objects (schema, namespaces, request pages, properties, triggers) and exporting data to Excel with the Excel Buffer table. It answers questions about moving data between Business Central and external sources in XML or Excel format.

Path: Development > Programming in the AL language > Tables and data > Importing and exporting data · tier official · system development · narrative reviewed (checked by Opus)

Overview

This section covers two ways to move data in and out of Business Central from AL code. XMLports import and export XML data between external sources and Business Central. Excel Buffer is a temporary table with methods for building Excel workbooks.

For XMLports, start with the “XMLport object” and “XMLport Overview for Business Central” pages. They explain what an XMLport is and describe its schema, request page, triggers, methods and properties such as Format and Direction. Then use “Defining an XMLport Schema in AL” to map XML elements to tables and fields. Use “Use Namespaces with XMLports in AL” when the external system needs XML namespaces. Use “Using request pages with XMLports” to let users set options and filters before a run.

For Excel, “Exporting data to Excel using ExcelBuffer” shows how to create a workbook, write rows, columns and cells, and either download it or save it to a stream.

Key points

  • XMLports export and import XML data between external sources and Business Central, and can include a request page for filtering, sorting, and choosing export or import.
  • An XMLport schema is built from textelement, textattribute, tableelement, fieldelement and fieldattribute nodes. The SourceTable property ties table elements to tables.
  • XMLport namespaces are set with the Namespaces, NamespacePrefix, DefaultNamespace and UseDefaultNamespace properties. They avoid element name conflicts with external systems.
  • XMLport request pages are configured with properties such as RequestFilterHeading, RequestFilterFields, AboutTitle, AboutText, ContextSensitiveHelpPage and SaveValues. The pages mention 2019 release wave 2 and 2023 release wave 1.
  • The XMLport overview covers the Format and Direction properties, triggers and methods.
  • Excel Buffer is a temporary table. You build workbooks with EnterCell, NewRow, AddColumn, CreateNewBook, WriteSheet and CloseBook.
  • Excel output can be downloaded with OpenExcel or exported to a stream with SaveToStream.

Learn pages

Videos, posts and code changes

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 6 Learn pages