rich_string.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Check for vtiful presence
  3. --SKIPIF--
  4. <?php if (!extension_loaded("xlswriter")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. $config = ['path' => './tests'];
  8. $fileObject = new \Vtiful\Kernel\Excel($config);
  9. $fileObject = $fileObject->fileName("rich_string.xlsx")
  10. ->header(['rich string']);
  11. $fileHandle = $fileObject->getHandle();
  12. $format1 = new \Vtiful\Kernel\Format($fileHandle);
  13. $colorRed = $format1->fontColor(\Vtiful\Kernel\Format::COLOR_GREEN)->toResource();
  14. $format2 = new \Vtiful\Kernel\Format($fileHandle);
  15. $colorOrange = $format2->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)->toResource();
  16. $richStringOne = new \Vtiful\Kernel\RichString('red ', $colorRed);
  17. $richStringTwo = new \Vtiful\Kernel\RichString('orange', $colorOrange);
  18. $fileObject->insertRichText(1, 0, [
  19. $richStringOne,
  20. $richStringTwo
  21. ]);
  22. $filePath = $fileObject->output();
  23. $data = $fileObject->openFile('rich_string.xlsx')
  24. ->openSheet()
  25. ->getSheetData();
  26. var_dump($filePath);
  27. var_dump($data);
  28. ?>
  29. --CLEAN--
  30. <?php
  31. @unlink(__DIR__ . '/rich_string.xlsx');
  32. ?>
  33. --EXPECT--
  34. string(24) "./tests/rich_string.xlsx"
  35. array(2) {
  36. [0]=>
  37. array(1) {
  38. [0]=>
  39. string(11) "rich string"
  40. }
  41. [1]=>
  42. array(1) {
  43. [0]=>
  44. string(10) "red orange"
  45. }
  46. }