Ignore blank cells

Test data preparation

$config = ['path' => './tests'];
$excel  = new \Vtiful\Kernel\Excel($config);

// Write test data
$filePath = $excel->fileName('tutorial.xlsx')
    ->header(['', 'Cost'])
    ->data([
        [],
        ['viest', '']
    ])
    ->output();

Example 1

// Read the full amount of data
// Use \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS to ignore blank cells

$data = $excel->openFile('tutorial.xlsx')
    ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS)
    ->getSheetData();

Example 2

// cursor mode
// Use \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS to ignore blank cells

$data = $excel->openFile('tutorial.xlsx')
    ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS);

while ($data = $excel->nextRow()) {
    var_dump($data);
}

Last updated