I will be pulling data from another array so, I'd probably just use that array's index as the iterator and let it control the "for" loop bounds.
The main drawback is that I'd still carry a temporary "character" variable that I'd remember to initialize before the loop and increment at the end within the loop. Much easier than building an elaborate function to do it, though.
You can always use the PHPExcel_Cell::stringFromColumnIndex($index) method (using the array's index) where 0 returns 'A', 1 returns'B', 25, returns'Z', 26 returns'AA', etc.
I'm very curious how localization (language, character set, encoding, collation sequence) would affect this style of character incrementation. Would this break it?
Character incrementing using the ++ operator only works with ASCII characters A-Z and a-z, and is case sensitive. It's a very useful quirk of PHP when working with Excel column names (pity the -- decrementor operator doesn't work with strings);
and I use it a lot in my own code.
I would prefer the reliability of having the "ByColumnAndRow" methods.
The duplicateStyle() method might be of some use when you want to replicate a style across a whole series of cells. Set the style for a single cell (or create a style object manually). e.g.
$objPHPExcel->getActiveSheet()->duplicateStyle(getStyleByColumnAndRow($pColumn = 0, $pRow = 1), $pRange = 'L3:N2048');
or you can set individual style elements across a range:
I do understand the effort required for good documentation. So very few people are interested in it and so few are good at it. The people qualified to do it usually would rather do code and their bosses would want them to code as well. I
will look for more of that documentation. Didn't know it was out there and didn't find a link to it. <<EDIT: I don't seem to have access to it. ??? http://phpexcel.codeplex.com/Documentation/API ???>><<EDIT2: DUNHH!!! I
was supposed to download and look at the html documentation files extracted from within. Functions/Methods I'm looking for still aren't there, though. :*( >>
Yes, the API documentation isn't here online on codeplex, but is included in the production downloads because it's built dynamically using PHPDocumentor as part of the release process.
The latest download also includes a couple of new sets of documents: the Functionality Cross-Reference.xls file, which I'll be building up slowly; and PHPExcel User Documentation – Reading Spreadsheet Files.doc with the corresponding set of Examples.
It's my intention to building this into a comprehensive set of documented, worked examples covering most of the functionality of the library... but you're right - like most developers, I'd far rather be developing than documenting. Now that the 1.7.5 release
is available, I'll try to devote some time to expanding this documentation before turning my focus to the code for the 1.7.6 release. I'll look at including a class diagram in that documentation for the next release; and one of these days I'll find the time
to start a blog, including scripted examples of PHPExcel recipes.