Skip to content

formulaAttributes are not written to file #1834

Closed
@Starocotes

Description

@Starocotes

This is:

- [X] 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 formulaAttributes you can set with the functions ->getCell()->setForumlaAttribtues() should be writen to the file with IWriter.

What is the current behavior?

You can get and set the attributes in the in memory sheet but those changes are not saved to the file.

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...
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getSheet(0);
$sheet->setCellValueByColumnAndRow(1,1,'1');
$sheet->setCellValueByColumnAndRow(1,2,'2');
$sheet->setCellValueByColumnAndRow(1,3,'2');
$sheet->setCellValueByColumnAndRow(1,4,'3');
$sheet->setCellValueByColumnAndRow(1,5,'=SUM(1/COUNTIFS(A1:A4,A1:A4))');

$sheet->getCell('K' . $row[$key])->setFormulaAttributes(['t' => 'array']);

$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($xls, "Xlsx");

$objWriter->setPreCalculateFormulas(false);
$objWriter->save('php://output');


### Which versions of PhpSpreadsheet and PHP are affected?
All

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions