open_xlsx_next_row_skip_empty.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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('open_xlsx_next_row_skip_empty.xlsx')
  13. ->header(['', 'Cost'])
  14. ->data([
  15. [],
  16. ['viest', ''],
  17. ])
  18. ->output();
  19. echo 'skip cells' . PHP_EOL;
  20. $data = $excel->openFile('open_xlsx_next_row_skip_empty.xlsx')
  21. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS);
  22. while (is_array($data = $excel->nextRow())) {
  23. var_dump($data);
  24. }
  25. echo 'skip row' . PHP_EOL;
  26. $data = $excel->openFile('open_xlsx_next_row_skip_empty.xlsx')
  27. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW);
  28. while (is_array($data = $excel->nextRow())) {
  29. var_dump($data);
  30. }
  31. echo 'skip cells & row' . PHP_EOL;
  32. $data = $excel->openFile('open_xlsx_next_row_skip_empty.xlsx')
  33. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS | \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW);
  34. while (is_array($data = $excel->nextRow())) {
  35. var_dump($data);
  36. }
  37. ?>
  38. --CLEAN--
  39. <?php
  40. @unlink(__DIR__ . '/open_xlsx_next_row_skip_empty.xlsx');
  41. ?>
  42. --EXPECT--
  43. skip cells
  44. array(1) {
  45. [1]=>
  46. string(4) "Cost"
  47. }
  48. array(0) {
  49. }
  50. array(1) {
  51. [0]=>
  52. string(5) "viest"
  53. }
  54. skip row
  55. array(2) {
  56. [0]=>
  57. string(0) ""
  58. [1]=>
  59. string(4) "Cost"
  60. }
  61. array(2) {
  62. [0]=>
  63. string(5) "viest"
  64. [1]=>
  65. string(0) ""
  66. }
  67. skip cells & row
  68. array(1) {
  69. [1]=>
  70. string(4) "Cost"
  71. }
  72. array(1) {
  73. [0]=>
  74. string(5) "viest"
  75. }