open_xlsx_get_data_skip_empty.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ?>
  32. --CLEAN--
  33. <?php
  34. @unlink(__DIR__ . '/tutorial.xlsx');
  35. ?>
  36. --EXPECT--
  37. array(3) {
  38. [0]=>
  39. array(1) {
  40. [0]=>
  41. string(4) "Cost"
  42. }
  43. [1]=>
  44. array(2) {
  45. [0]=>
  46. string(0) ""
  47. [1]=>
  48. string(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. [0]=>
  76. string(4) "Cost"
  77. }
  78. [1]=>
  79. array(1) {
  80. [0]=>
  81. string(5) "viest"
  82. }
  83. }