print a range area

Topics: Developer Forum, Project Management Forum, User Forum
Dec 20, 2013 at 3:49 PM
i need to store in a variale the content of a cell area and after print the value.

The code that i use is
echo $type;
but it doesn't work..How can i do?

Dec 23, 2013 at 8:37 AM
there's someone who can help me?
Dec 23, 2013 at 11:28 AM
setAutofilter returns a Worksheet object, which is unlikely to match what you want, and that is not viewable (except by a var_dump or equivalent).
The cells you want to display are selected by an automatic filter? If so, I advise you to read the documentation (PHPExcel AutoFilter Reference), you will find an example explaining how to apply a filter before saving the file (by default, the filter is applied at this time) and a sample display of filtered cells.

Otherwise... Be more specific in your request.
Dec 23, 2013 at 12:09 PM
in this case what i have to do is store the content of the range area C4:A4 in a variable and after print it. How can i do it? I can't find other example in a phpExcel documentation.

Dec 23, 2013 at 12:40 PM
You can use rangeToArray :
$arrayValue contains a simple array with your 3 values.
Dec 23, 2013 at 1:17 PM
Edited Dec 23, 2013 at 1:37 PM
This is my code:

$total= count($arrayValues);

for ($i=0 ; $i<= $total ; $i++)
echo $arrayValues[$i];              

but i have this error

Notice: Array to string conversion in C:\Program Files (x86)\EasyPHP-12.1x2.... on line 93
Notice: Undefined offset: 1 in C:\Program Files (x86)\EasyPHP-12.1x2.... on line 93

what can i do?
Dec 23, 2013 at 3:05 PM
ah, yes, you have an array by row, with an array with row cells (do a var_dump to see).
//values for test
$F  ->setCellValue('C2', 10)
    ->setCellValue('D2', 20)
    ->setCellValue('E2', 30);
//extract values
if(is_array($arrayValues) && array_key_exists(0, $arrayValues) && is_array($arrayValues[0])){
    foreach($arrayValues[0] as $aValue){
        echo $aValue;
    echo 'something wrong...';