Php – How do i change cell values with PHPExcel without change cell’s style

PHPphpexcel

I'm writting a web application that modify some cells of an already existing excel's file, i'm using PHPExcel to do that, but when i use the setValue function of a cell, it clean the style of the cell. Also i tried using getActiveSheet()->setCellValue but it also clean the cell's style.

How i can change the cell's value without touching it style? It is possible with PHPExcel? Thanks.

Edit: The existing file has it cells formated with background color, borders, format of numbers, etc, and when i edit the cell value with PHPExcel, all of that is deleted and replaced with a blank cell with the value that i set, I want to conserve the style/format of the cell when i set it value, thanks!

Best Answer

Finally i found the answer, here: http://phpexcel.codeplex.com/discussions/213643

setCellValue & setValue appears to create a new cell and place it over the old one, but if you use setCellValueByColumnAndRow your old cell style and format will be conserved!

tl;dr: Use setCellValueByColumnAndRow instead.

Related Topic