You are here

public function PHPExcelTest::testIssue2501147 in PHPExcel 7.3

Empty cells must be imported as empty strings, and not shift adjacent cells to the left.

See also

http://drupal.org/node/2501147

File

tests/phpexcel.test, line 164
Defines the test case for phpexcel

Class

PHPExcelTest
@file Defines the test case for phpexcel

Code

public function testIssue2501147() {

  // Import.
  $data = phpexcel_import(dirname(__FILE__) . '/data/phpexcel.test.empty_cells.xlsx', FALSE);
  $this
    ->assertTrue(!!$data, 'Import succeeded');

  // Second row, 1st cell should be 'Data 1.1'.
  $cell = $data[0][1][0];
  $this
    ->assertTrue($cell === 'Data 1.1', 'Second row, 1st cell data should be "Data 1.1"');

  // Second row, 2nd cell should be 'Data 1.2'.
  $cell = $data[0][1][1];
  $this
    ->assertTrue($cell === 'Data 1.2', 'Second row, 2nd cell data should be "Data 1.2"');

  // Third row, 1st cell should be ''.
  $cell = $data[0][2][0];
  $this
    ->assertTrue($cell === '', 'Third row, 2nd cell data should be "" (empty string)');

  // Third row, 2nd cell should be 'Data 2.2'.
  $cell = $data[0][2][1];
  $this
    ->assertTrue($cell === 'Data 2.2', 'Second row, 2nd cell data should be "Data 2.2"');

  // Fourth row, 1st cell should be 'Data 3.1'.
  $cell = $data[0][3][0];
  $this
    ->assertTrue($cell === 'Data 3.1', 'Fourth row, 1st cell data should be "Data 3.1"');

  // Fourth row, 2nd cell should be ''.
  $cell = $data[0][3][1];
  $this
    ->assertTrue($cell === '', 'Fourth row, 2nd cell data should be "" (empty string)');
}