xlsx_to_csv_custom_delimiter.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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('xlsx_to_csv_custom_delimiter.xlsx', 'TestSheet1')
  13. ->header(['Item', 'Cost'])
  14. ->data([
  15. ['Item_1', 'Cost_1', 10, 10.9999995],
  16. ])
  17. ->output();
  18. $fp = fopen('./tests/file.csv', 'w');
  19. $csvResult = $excel->openFile('xlsx_to_csv_custom_delimiter.xlsx')
  20. ->openSheet()
  21. ->putCSV($fp, ';');
  22. var_dump($csvResult);
  23. if (($csvHandler = fopen('./tests/file.csv', 'r')) === FALSE) {
  24. die('csv file open failure');
  25. }
  26. while (($data = fgetcsv($csvHandler, 1000, ';')) !== FALSE) {
  27. var_dump($data);
  28. }
  29. ?>
  30. --CLEAN--
  31. <?php
  32. @unlink(__DIR__ . '/xlsx_to_csv_custom_delimiter.xlsx');
  33. @unlink(__DIR__ . '/file.csv');
  34. ?>
  35. --EXPECT--
  36. bool(true)
  37. array(2) {
  38. [0]=>
  39. string(4) "Item"
  40. [1]=>
  41. string(4) "Cost"
  42. }
  43. array(4) {
  44. [0]=>
  45. string(6) "Item_1"
  46. [1]=>
  47. string(6) "Cost_1"
  48. [2]=>
  49. string(2) "10"
  50. [3]=>
  51. string(10) "10.9999995"
  52. }