open_xlsx_get_data_skip_empty.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. $data = $excel->openFile('tutorial.xlsx')
  20. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS)
  21. ->getSheetData();
  22. var_dump($data);
  23. $data = $excel->openFile('tutorial.xlsx')
  24. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_ROW)
  25. ->getSheetData();
  26. var_dump($data);
  27. $data = $excel->openFile('tutorial.xlsx')
  28. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_CELLS|\Vtiful\Kernel\Excel::SKIP_EMPTY_ROW)
  29. ->getSheetData();
  30. var_dump($data);
  31. $data = $excel->openFile('tutorial.xlsx')
  32. ->openSheet('Sheet1', \Vtiful\Kernel\Excel::SKIP_EMPTY_VALUE)
  33. ->getSheetData();
  34. var_dump($data);
  35. ?>
  36. --CLEAN--
  37. <?php
  38. @unlink(__DIR__ . '/tutorial.xlsx');
  39. ?>
  40. --EXPECT--
  41. array(3) {
  42. [0]=>
  43. array(1) {
  44. [1]=>
  45. string(4) "Cost"
  46. }
  47. [1]=>
  48. array(0) {
  49. }
  50. [2]=>
  51. array(1) {
  52. [0]=>
  53. string(5) "viest"
  54. }
  55. }
  56. array(2) {
  57. [0]=>
  58. array(2) {
  59. [0]=>
  60. string(0) ""
  61. [1]=>
  62. string(4) "Cost"
  63. }
  64. [1]=>
  65. array(2) {
  66. [0]=>
  67. string(5) "viest"
  68. [1]=>
  69. string(0) ""
  70. }
  71. }
  72. array(2) {
  73. [0]=>
  74. array(1) {
  75. [1]=>
  76. string(4) "Cost"
  77. }
  78. [1]=>
  79. array(1) {
  80. [0]=>
  81. string(5) "viest"
  82. }
  83. }
  84. array(3) {
  85. [0]=>
  86. array(1) {
  87. [1]=>
  88. string(4) "Cost"
  89. }
  90. [1]=>
  91. array(0) {
  92. }
  93. [2]=>
  94. array(1) {
  95. [0]=>
  96. string(5) "viest"
  97. }
  98. }