open_xlsx_get_data_skip_empty.phpt 1.3 KB

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