Reputation: 1989
In the docs
i didn't find any useful function for my need.
Is it possible to "reset" / "delete the entire formatting" of a single cell? Return the cell to its original state.
Upvotes: 1
Views: 1979
Reputation: 142
Instead of "undoing" all of your previous style changes, you can duplicate a cell style (that you didn't change) to your desired reset cell/range.
@param string $range Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
function resetStyle(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, string $range): void
{
$worksheet->duplicateStyle(
$worksheet->getStyle('ZZ99999'),
$range
);
}
Upvotes: 0
Reputation: 76849
explicitly undoing the previous format should work:
$ws->getStyle('A1')->applyFromArray(array(
'font' => array('bold' => false)
));
when importing, one can also skip formats altogether: $reader->setReadDataOnly(true);
Upvotes: 5