I would like to copy all the data and the style of a certain range to other cells. for example I want to copy from A4: I15 and then paste exactly want I copied the contents and
I found a solution without additional code:
setReadDataOnly(false);
$spreadsheet = $reader->load('old_file.xlsx');
$worksheet = $spreadsheet->getActiveSheet();
/** Iterate needed cells in $worksheet and change their values **/
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('new_file.xlsx');
The important part is to set option $reader->setReadDataOnly(false) (which is set by default) because if option is set to true then only data without styles are read.