Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writer yielding corrupted output spreadsheet given non-corrupted input spreadsheet #2401

Closed
ornithophile opened this issue Nov 18, 2021 · 3 comments

Comments

@ornithophile
Copy link

ornithophile commented Nov 18, 2021

This is:

- [X] a bug report

What is the expected behavior?

To open the spreadsheet, fill in the cell values, and produce a usable spreadsheet.

What is the current behavior?

Excel indicates that the spreadsheet is corrupted; the input spreadsheet is not.

What are the steps to reproduce?

<?php
require __DIR__ . '/vendor/autoload.php';

$xlsxPayload = [
  'C2' => 'Enphase IQ7-60-2-US',
  'C3' => 'Hanwha Q CELLS Q.PEAK DUO BLK-G6+ 340',
  'C12' => '123 fake st',
  'C13' => 'Fake, CA 99999',
  'C14' => 'Fake Person',
  'C15' => '6612342324',
  'C16' => '11/17/2021',
  'C40' => '11/17/2021',
  'C20' => 16,
  'C46' => 206,
  'C52' => 21,
  'C21' => 0,
  'C47' => 0,
  'C53' => 0,
  'C22' => 0,
  'C48' => 0,
  'C54' => 0,
  'C23' => 0,
  'C49' => 0,
  'C55' => 0,
  'C24' => 0,
  'C50' => 0,
  'C56' => 0,
];

try {
  $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
  $spreadsheet = $reader->load("Design_Form.xlsx");
  $sheet = $spreadsheet->getSheetByName('Inputs');
  foreach ($xlsxPayload as $cell => $value)
    $sheet->setCellValue($cell, $value);
  $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
  $writer->save("Output.xlsx");
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
  echo $e->getMessage();
} catch (\PhpOffice\PhpSpreadsheet\Writer\Exception $e) {
  echo $e->getMessage();
}
?>

Which versions of PhpSpreadsheet and PHP are affected?

1.19 / 7.4

@ornithophile
Copy link
Author

image

image

@ornithophile
Copy link
Author

@oleibman
Copy link
Collaborator

Closing as duplicate of #2368. File contains Data Validations. Fix is available in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants