Ignore blank lines

Test data preparation

1
$config = ['path' => './tests'];
2
$excel = new \Vtiful\Kernel\Excel($config);
3
4
// Write test data
5
$filePath = $excel->fileName('tutorial.xlsx')
6
->header(['', 'Cost'])
7
->data([
8
[],
9
['viest', '']
10
])
11
->output();
Copied!

Example 1

1
// Read the full amount of data
2
// Use \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW to ignore blank lines
3
4
$data = $excel->openFile('tutorial.xlsx')
5
->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW)
6
->getSheetData();
Copied!

Example 2

1
// cursor mode
2
// Use \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS to ignore blank lines
3
4
$data = $excel->openFile('tutorial.xlsx')
5
->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW);
6
7
while ($data = $excel->nextRow()) {
8
var_dump($data);
9
}
Copied!
Last modified 2yr ago