fromArray() writes only the first letter of the arrays content from a form to excel file

Topics: Developer Forum, User Forum
Dec 10, 2009 at 4:15 PM
Edited Dec 10, 2009 at 4:15 PM

i use fromArray to fill my excel file with content submitted from a form, but the fromArray function writes only the first letter of the arrays content in my excel file
the other variables, which are not arrays, are ok

i use: $objPHPExcel->getActiveSheet()->fromArray($apps, 10, 'G6');

mArray($apps, 10, 'G6');
between the variable and the cell is a $nullvalue, i wrote 10 therefor, i don't really understand what it is for...

please help me.
Developer
Jan 20, 2010 at 11:25 AM
moubou wrote:

i use fromArray to fill my excel file with content submitted from a form, but the fromArray function writes only the first letter of the arrays content in my excel file
the other variables, which are not arrays, are ok

i use: $objPHPExcel->getActiveSheet()->fromArray($apps, 10, 'G6');

mArray($apps, 10, 'G6');
between the variable and the cell is a $nullvalue, i wrote 10 therefor, i don't really understand what it is for...

please help me.

In your source array, $apps, you may have some custom symbol to indicate when a cell is blank. The second parameter is used to indicate what that custom symbol is. By default it is null, but you may be using something else.

Try to use this:

$objPHPExcel->getActiveSheet()->fromArray($apps, null, 'G6');
Sep 1, 2010 at 9:45 AM
Edited Sep 1, 2010 at 9:46 AM
moubou wrote:

i use fromArray to fill my excel file with content submitted from a form, but the fromArray function writes only the first letter of the arrays content in my excel file
the other variables, which are not arrays, are ok

Since your first question hasn't been answered yet and I encountered the same problem. Here comes the solutions:

The method fromArray() expects an array where as each element represents a row. Therefore to make things work you got to have to make each element an array, too.

Example:

$source = 

Array (

    [0] => Array
        (
            [0] => CellA1
            [1] => CellB1
            [2] => CellC1
        )
    [1] => Array
        (
            [0] => CellA2
            [1] => CellB2
            [2] => CellC2
        )
)