Import/Export File in Business Central using Al Language

Hello, I’m new in Business Central and i’m using AL language to implement functionality, Please anyone suggest me how to import and export excel file in business central it’s urgent for me. Thanks in advance.


hope this example code can get You started…

Hi Gautam,

Which Business Central are you using? The Azure/SAAS D365 BC or NAV 2018 on premise? And which version are you referring to? Currently released, or sandbox/previews?

If you are using the true Business Central (hosted) then you are not able to work directly with files as you are used to. Whereas you can still use predefined tools as Excel Buffer, then you cannot code something which read files directly from the file system. Just as you cannot do anything which requires .net.

If you are on premise and build internal extensions, then you have a few more options, like accessing files.

Hi Erik, I’m using NAV 2018 on premise and Version-sandbox/previews.

Hi Orjan, Can you provide me some more code example in AL language to import file, I have created a xml file with 4 fields and also have created a table with 4 fields that I have in my xml file. I want to store data from the imported file, I want to create a page that can ask to “select file” after select desired file should import file data to the respective table.

When I try to Import file, I got the Warning Alert “The Data File cannot be read by this version of Business Central”.

Which code are you accessing when getting this error?


What is your build target in the extension App.json? Must be set to Internal to be able to use “on-premise” options.


I haven’t define target in App.json file.

Then it will use the default target: Extension.

In that case try to add the above live.

Which AL build are you using?