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

Hidden Rows in Excel File Saved with PhpSpreadsheet #4235

Open
1 of 8 tasks
wenpinglee opened this issue Nov 20, 2024 · 1 comment
Open
1 of 8 tasks

Hidden Rows in Excel File Saved with PhpSpreadsheet #4235

wenpinglee opened this issue Nov 20, 2024 · 1 comment

Comments

@wenpinglee
Copy link

wenpinglee commented Nov 20, 2024

Hello,

I am experiencing an issue with PhpSpreadsheet when saving an Excel file. The problem is that some rows in the saved file are hidden, even though they are not supposed to be.

- [V] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

The data is displayed correctly in the Excel sheet.

What is the current behavior?

The rows are all hidden, only the title remains.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$templatePath = storage_path('app/public/Sample_Request.xlsx');
$spreadsheet = IOFactory::load($templatePath);

$spreadsheet1 = IOFactory::load($filePath);//copy other excel
$sheet1 = $spreadsheet1->getSheet(0);

$spreadsheet->addSheet($sheet1, 1);
$sheet2 = $spreadsheet->getSheet(1);
for ($k = 1; $k <= 1000; $k++) {
    $sheet2->getRowDimension($k)->setCollapsed(false);
    $sheet2->getRowDimension($k)->setVisible(true);
}
$newFilePath = storage_path('app/public/temp/test.xlsx');
$writer = new Xlsx($spreadsheet);
$writer->save($newFilePath);

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

After saving the file, some rows are hidden when I open it in Excel.I don't think this issue is caused by the file($filePath).

Which versions of PhpSpreadsheet and PHP are affected?

phpoffice/phpspreadsheet version 1.29.0
maatwebsite/excel version 3.1.55
laravel version 9.52.16
PHP version 8.0.24

@oleibman
Copy link
Collaborator

It is difficult to debug this problem without the file which demonstrates it. Is it possible to upload it? There are other factors affecting visibility besides the RowDimension property. Rows might, for example, be hidden due to an auto-filter, and the RowDimension property will not override that.

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