Few questions about multiple rows/cold modifications.

Topics: Developer Forum
Feb 28, 2014 at 9:24 AM
- This doesn't work for me (documentation say it should). I want to apply style to all columns in specified row/col
I have to solve it like this:
$x = \PHPExcel_Cell::stringFromColumnIndex(33);
$headers = $report->getActiveSheet()->getStyle("A1:{$x}1");
- Is there way to set width to many columns without using loop? Something like this:
- Is there option to use integers instead of letters to identify columns?
Manual translating numbers to letters is kinda code consuming.
Thx for any support!
Feb 28, 2014 at 9:59 AM
Can you point me to where in the documentation it says that you can apply styles to a row or a column, because the documentation is wrong, and row/column styles have never been supported by any version of PHPExcel to date
Feb 28, 2014 at 10:59 AM
Documentation just say that it apply cell range. I didn't dig deeper but Worksheet::getStyle() use Worksheet::setSelectedCells();
Worksheet::setSelectedCells() results for getStyle($x):
$x = 'A1'; -> A1 (works)
$x = 'A1:B2'; -> A1:B2 (works)
$x = 'A1:B2'; -> A1:A900 (works)
$x = 'A'; -> A1:A1048576 (don't)
$x = '1' -> A1:XFD1 (don't)
Method is selecting proper columns so I don't understand why A1:A900 is correct but A1:A1048576 is not. I wouldn't write here if I wouldn't found such functionality in code.

What about other questions?

Big thanx for help!
Mar 31, 2014 at 2:57 PM
I'm having exactly same problem.
Why is getActiveSheet()->getStyle('A') not working as expected ?
Like Jifer already said, there's some code in PHPExcel_Worksheet::setSelectedCells() to convert coordinate 'A' into 'A1:A1048576'.
If it's not supported by PHPExcel, why adding such (wrong) code ? Just to avoid throwing errors when coordinates are invalid ?

Thanx for help.
Mar 31, 2014 at 10:42 PM
There is built in function to convert integers to cols (don't have code now, so I will not paste it here). It is quite easy to know how many row/cols you want to select. So I convert it to XX:88 using built in function and then I select style (or other stuff). Easy workaround.

Also what I would notice is that above code actually works, but not as we expect. Lets say you have 10 rows. You will set style to 1000 rows. Now we have some fun, because when you open your xslx file it will have all 1000 lines visible, not 10. It will be also x times heavier. So making A1:XFD1 (A) is just impossible because of memory consumption to handle this.
There should be something like getStyle('A', TRUE) which would get all used A:? fields (TRUE flag for "get available").