xlsx_to_csv_skip_rows_callback.phpt 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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', 'TestSheet1')
  13. ->header(['Item', 'Cost'])
  14. ->data([
  15. ['Item_1', 'Cost_1', 10, 10.9999995],
  16. ['Item_2', 'Cost_2', 10, 10.9999995],
  17. ['Item_3', 'Cost_3', 10, 10.9999995],
  18. ])
  19. ->output();
  20. $fp = fopen('./tests/file.csv', 'w');
  21. $csvResult = $excel->openFile('tutorial.xlsx')
  22. ->openSheet()
  23. ->setSkipRows(3)
  24. ->putCSVCallback(function($row){
  25. return $row;
  26. }, $fp);
  27. fclose($fp);
  28. var_dump($csvResult);
  29. var_dump(file_get_contents('./tests/file.csv'));
  30. ?>
  31. --CLEAN--
  32. <?php
  33. @unlink(__DIR__ . '/tutorial.xlsx');
  34. @unlink(__DIR__ . '/file.csv');
  35. ?>
  36. --EXPECT--
  37. bool(true)
  38. string(28) "Item_3,Cost_3,10,10.9999995
  39. "