You are here

protected function XlsTest::loadXlsFile in Excel Serialization 8

Helper function to retrieve an xls object for a xls file.

Parameters

object $xls: The xls file contents.

string $format: The format the xls file is in. Defaults to 'xls'.

Return value

\PHPExcel The excel object.

2 calls to XlsTest::loadXlsFile()
XlsTest::testEncode in tests/src/Unit/Encoder/XlsTest.php
@covers ::encode
XlsTest::testEncodeMetaData in tests/src/Unit/Encoder/XlsTest.php
Tests metadata.

File

tests/src/Unit/Encoder/XlsTest.php, line 121

Class

XlsTest
Tests the XLS encoder.

Namespace

Drupal\Tests\xls_serialization\Unit\Encoder

Code

protected function loadXlsFile($xls, $format = 'xls') {

  // PHPExcel only supports files, so write the xls to a temporary file.
  $xls_file = @tempnam(File::sysGetTempDir(), 'phpxltmp.' . $format);
  file_put_contents($xls_file, $xls);
  return IOFactory::load($xls_file);
}