open_xlsx_next_row_skip_empty.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --TEST--
  2. Check for vtiful presence
  3. --SKIPIF--
  4. <?php
  5. require __DIR__ . '/include/skipif.inc';
  6. skip_disable_reader();
  7. ?>
  8. --FILE--
  9. <?php
  10. $config = ['path' => './tests'];
  11. $excel = new \Vtiful\Kernel\Excel($config);
  12. $filePath = $excel->fileName('tutorial.xlsx')
  13. ->header(['', 'Cost'])
  14. ->data([
  15. [],
  16. ['viest', ''],
  17. ])
  18. ->output();
  19. echo 'skip cells' . PHP_EOL;
  20. $data = $excel->openFile('tutorial.xlsx')
  21. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS);
  22. while ($data = $excel->nextRow()) {
  23. var_dump($data);
  24. }
  25. echo 'skip row' . PHP_EOL;
  26. $data = $excel->openFile('tutorial.xlsx')
  27. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW);
  28. while ($data = $excel->nextRow()) {
  29. var_dump($data);
  30. }
  31. echo 'skip cells & row' . PHP_EOL;
  32. $data = $excel->openFile('tutorial.xlsx')
  33. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS | \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW);
  34. while ($data = $excel->nextRow()) {
  35. var_dump($data);
  36. }
  37. ?>
  38. --CLEAN--
  39. <?php
  40. @unlink(__DIR__ . '/tutorial.xlsx');
  41. ?>
  42. --EXPECT--
  43. skip cells
  44. array(1) {
  45. [0]=>
  46. string(4) "Cost"
  47. }
  48. array(1) {
  49. [0]=>
  50. string(5) "viest"
  51. }
  52. skip row
  53. array(2) {
  54. [0]=>
  55. string(0) ""
  56. [1]=>
  57. string(4) "Cost"
  58. }
  59. array(2) {
  60. [0]=>
  61. string(5) "viest"
  62. [1]=>
  63. string(0) ""
  64. }
  65. skip cells & row
  66. array(1) {
  67. [0]=>
  68. string(4) "Cost"
  69. }
  70. array(1) {
  71. [0]=>
  72. string(5) "viest"
  73. }