
In this article we will discuss regarding how to export data from business central in CSV Format.
CSV Export is built in feature of Business Central.
This article explains how to export CSV files from Microsoft Dynamics 365 Business Central using the CSV Buffer table, including common problems developers face and the best practices to avoid them.
It is written for Business Central developers who need a reliable, integration-safe CSV export, not an Excel-based workaround.
Business Central customers often request “Excel export”, but in most real-world scenarios, the actual requirement is:
Data transfer to an external system
Import into another ERP, WMS, or reporting tool
Automation or scheduled data exchange
In these cases, CSV is the correct format, not Excel.
CSV Buffer is a built-in table in Business Central (and legacy NAV) designed specifically for CSV file handling.
| Field | Purpose |
|---|---|
| Line No. | Represents the row number |
| Field No. | Represents the column number |
| Value | The actual data value (Text, max 250 chars) |
This structure allows developers to:
Control column order
Add headers explicitly
Apply formatting rules
Handle large datasets efficiently
A standard and scalable CSV export pattern looks like this:
User clicks an Export CSV action
Action calls a codeunit
Codeunit:
Uses temporary CSV Buffer
Adds header row
Inserts data row by row
Writes content to a Blob
Downloads the file to the client
This pattern is upgrade-safe, testable, and performant.
Problem:
Text fields like item descriptions contain commas, causing column shifts in Excel or external systems.
Cause:
CSV format treats commas as separators.
Solution:
Sanitize text values before inserting them into CSV Buffer (e.g., remove or replace commas).
Problem:
CSV files without headers are unclear and error-prone.
Cause:
Developers skip header creation.
Solution:
Always insert headers using:
Field captions, or
Explicit column names
Problem:
Fields like Inventory show incorrect values.
Cause:
FlowFields are not calculated automatically.
Solution:
Use:
CalcFields
or SetAutoCalcFields
When exporting large datasets:
Use SetLoadFields to fetch only required fields
Avoid unnecessary FlowField calculations
Keep CSV Buffer temporary
Do not load full records when not needed
These steps significantly reduce memory usage and execution time.
Despite the name, CSV does not require commas.
You may use:
Semicolons (;)
Colons (:)
Pipes (|)
Excel and most tools can interpret custom separators using Text to Columns.
This is especially useful when:
Data frequently contains commas
CSV is consumed by non-Excel systems
Yes.
CSV Buffer supports:
Exporting CSV
Importing CSV
This makes it a versatile tool for two-way data exchange in Business Central.
Avoid CSV Buffer when:
The requirement is a formatted Excel report
Users need formulas, styling, or pivot tables
The output is purely for human analysis, not integration
In those cases, Excel-based approaches are more appropriate.
Use CSV Buffer when:
Exporting structured data
Integrating with external systems
Performance and control matter
Avoid CSV Buffer when:
Excel formatting is required
Key Concepts:
CSV Buffer table
FlowFields and CalcFields
Data sanitization
Custom separators
Performance optimization
This article is part of a Business Central data export series focused on real-world developer scenarios and best practices.
Subscribe to the YouTube channel
Join the Business Central developer community
Explore advanced AL, performance, and API topics
Original Post https://www.sauravdhyani.com/2026/04/how-to-export-csv-files-from-business.html






