-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Format number and conditionnal type at the same time #47
Comments
Which writer do you use ? |
I instanciate the PHPExcel_Writer_Excel2007 writer |
This was certainly true for 1.7.7, but I've already fixed this issue on the develop branch here on github. Using the following code to try and replicate your problem:
This works correctly: both the conditional background colour and the number format styles are maintained when the spreadsheet is saved. As I'm unable to replicate this issue, can you please upload a sample code that demonstrates your problem to the phpexcel.codeplex.com site. |
Hi Mark, sorry about the long silence, my boss need my help on other work... I try your code but i get an error : Class PHPExcelIOFactory not found. Where do i lost myself ? When i use 1.7.7 writer style call : $writer = new PHPExcel_Writer_Excel2007($objPHPExcel); I still get the original issue. bug seems to be fix on the writer. Regards, |
The PHPExcel_IOFactory class is in the file IOFactory.php in the /Classes/PHPExcel directory.... if your script can't find that, then something is very, very wrong indeed... like the PHPExcel code is missing or not defined in the path (though I'd expect PHPExcel.php to be problematic as well if that was the case) |
oh crap... I copy from the email which contain : and not this : $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); "_" change all... So i can try your code. |
I try your code and get the same issue as before. A1 get a green color font with 0,25 in cell To get A1 with 25% display i need to get in conditionnal cell I can send you the xls file if you want. |
I've done ! // ############################ this don't work ############################ // style apply // ############################ this work ################################ issu seems to come from "applyFromArray" method. Regards, |
Hi, I have the same problem with 1.7.9 and the git develop branch. Tested with my code as well as Mark's code from above. Basically, if you don't explicitly specify a number format in the conditional style array PHPExcel will always use "General". That means all cells that match the rule will be formated as General independent of what the original cell format is. Ajouno's solution of explicitly setting the format isn't really an option for me, because my conditional format spans multiple columns with different number formats. As far as I can tell the problem is in Style/NumberFormat.php lines 202-214: public function setFormatCode, which sets the number format to "General" if none is specified. I tested it by commenting line 205 and the result is what I expected. If no format is specified then no format is applied and all cells preserve their original formating. But this does cause some PHP warnings down the line, specifically in the function getHashCode() line 366 of the same file. EDIT: I just realized I also had to explicitly set the conditional number format to null, otherwise it doesn't work. I hope this help you fix this issue. |
using 1.7.7 and same trying 1.7.8 RC3-3
I get a cell with a pourcent number format style
This cell get a conditionnal style too.
the background color change is cell is > or < 0
Conditionnal works great but after the conditionnal apply the number format is loose. :(
What about the good pratice about that ?
Thanks a lot for your job
ajouno
The text was updated successfully, but these errors were encountered: