MNB PHPExcelDeveloper Guide
JSON module

JSON Module

Read and write JSON arrays, workbook-shaped objects, JSON Lines, and NDJSON with streaming support.

Updated

LevelAll levelsReading time6 minPackagemnb/mnb-phpexcel
Json::read()Json::write()JsonReader::readWorkbook()JsonWriter::payloadToString()

What you will learn

  • Choose standard JSON, top-level array streaming, or NDJSON.
  • Normalize records into a spreadsheet-style row session.
  • Write rows or complete workbook payloads.

Install the JSON package#

Terminal
composer require mnb/mnb-phpexcel:^2.0

Supported document shapes#

ShapeBehavior
Top-level row arrayStreams items one at a time by default.
NDJSON / JSON LinesReads one JSON value per non-empty line.
Workbook-shaped objectMaterializes document structure so named sheets can be selected.
Single object or nested dataNormalized according to json_mode and column options.

Read and write rows#

read-json.php
use Mnb\PHPExcel\Format\Json;

$rows = Json::read('customers.json')
    ->withHeaderRow(1)
    ->rows();