Skip to content
MNB PHPExcelDeveloper Guide
AI

CSV library

Writing CSV and TSV Files

Generate atomic, Excel-friendly delimited files with BOM, encoding, dialect, and injection controls.

Level
Intermediate
Reading time
7 min
Package
mnb/mnb-phpexcel-csv
Updated
Csv::write()CsvDialect::resolve()

Write an Excel-friendly CSV#

PHP
Csv::write($rows, 'report.csv', [
    'with_header' => true,
    'dialect' => 'excel',
    'encoding' => 'UTF-8',
    'bom' => true,
    'injection_policy' => 'escape',
]);

Choose a dialect preset#

PresetDelimiterLine endingBOM
excelCommaCRLFYes
excel_tabTabCRLFYes
semicolonSemicolonCRLFYes
unixCommaLFNo
pipePipeLFNo

Prevent formula injection#