open_xlsx_next_row_skip_empty.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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(2) {
  49. [0]=>
  50. string(0) ""
  51. [1]=>
  52. string(0) ""
  53. }
  54. array(1) {
  55. [0]=>
  56. string(5) "viest"
  57. }
  58. skip row
  59. array(2) {
  60. [0]=>
  61. string(0) ""
  62. [1]=>
  63. string(4) "Cost"
  64. }
  65. array(2) {
  66. [0]=>
  67. string(5) "viest"
  68. [1]=>
  69. string(0) ""
  70. }
  71. skip cells & row
  72. array(1) {
  73. [0]=>
  74. string(4) "Cost"
  75. }
  76. array(1) {
  77. [0]=>
  78. string(5) "viest"
  79. }