Cells, Ranges, and Projection
Read individual values, typed metadata snapshots, rectangular ranges, and selected columns.
Updated
cell()cells()cellDetails()rangeValues()rangeStyles()projectColumns()What you will learn
- Use cell access for lookup-style workbooks.
- Use ranges for compact rectangular data.
- Project columns before normalization to reduce work.
Read one or several cells#
$sheet = MnbExcel::read('finance.xlsx')->sheet('Summary');
$total = $sheet->cell('D12');
$values = $sheet->cells(['B2', 'D12', 'F20']);Read a complete cell snapshot#
$cell = MnbExcel::read('finance.xlsx')
->sheet('Summary')
->cellDetails('D12');
printf("Coordinate: %s\n", $cell->coordinate);
printf("Formula: %s\n", $cell->formula ?? 'none');
print_r($cell->style);A snapshot may include formula information, number format, style, hyperlink, comment, protection, rich text, and merged-range membership.
Read a rectangular range#
$matrix = MnbExcel::read('finance.xlsx')
->sheet('Summary')
->rangeValues('A1:F20');Project only required columns#
$rows = MnbExcel::read('orders.xlsx')
->sheet('Orders')
->withHeaderRow(1)
->projectColumns(['Order ID', 'Customer', 'Amount'])
->streaming()
->rows();Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue