Insert an entire row at once to XLSx

Topics: Developer Forum
Jul 6, 2010 at 2:10 PM
Edited Jul 6, 2010 at 2:35 PM
Hi guys/girls,

I am having a bit of a problem inserting an entire row at once.
Let me begin to explain the situation...

I have an array of different names. These names can be 100 names, but can also be 1000 names.

1. Is it possible to insert the array as a row (ofcourse in different columns) all at once?
2. (if not, ) Is it possible to insert 1 name, check what the next column-identifier should be (e.a. the last name was put in A, the next column-identifier should be B) ??

With one of those solutions I wouldn't get the problem that Z is the column before AA.

Very best regards,

edit: fixed linebreaks

I have found the functions
columnIndexFromString and stringFromColumnIndex
Which I might be able to use to check what ID is the current column, add 1, and get back the new columnid..
I'm going to break my head on this for a while...
Jul 7, 2010 at 4:59 AM

If you figure this out please post the solution, I'm need to do the exact same thing.

Jul 7, 2010 at 5:37 AM

Vamos, I decided to RTFM before someone else told me to, and I found example 4.5.5 for how to use the built in iterators to easily loop through cells without having to use letters. While this isn't as ideal as just passing an array, it would be really simple just to loop through that array and use the standard methods to set the value of that cell.

Jul 7, 2010 at 8:06 AM
Edited Jul 7, 2010 at 8:42 AM
Hi Fillup,
I found out how to do it.
You can use the 2 functions to check what the current column is and what the next should be (stringFromColumnIndex somehow even returns the next string instead of the current)

This is what I did:

if (empty ( $columnID ))
$columnID = 'A';
$iNextColumn = $this->columnIndexFromString ( $columnID );
$columnID = $this->stringFromColumnIndex ( $iNextColumn );

edit: btw, I wasn't able to use the function without copy/pasting it to my own class.. If I used from Cell.php I somehow got an error (don't remember what it was)