Undefined index: margin-left

Topics: Developer Forum, Project Management Forum, User Forum
Feb 9, 2012 at 6:54 PM

Hy

i try insert head and footer using template, but in moment that my app read the file, the program show following error:

Notice: Undefined index: margin-left in C:\Users\operador\wamp\www\hidrocontroll\util\excelMicrosoft\PHPExcel\Reader\Excel2007.php on line <i>1263</i>

 

C:\Users\operador\wamp\www\hidrocontroll\scripts\relatorioClima\gerarRelatorioExcel.php' bgcolor='#eeeeec'>..\gerarRelatorioExcel.php<b>:</b>102</td></tr>


<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>0.0411</td><td bgcolor='#eeeeec' align='right'>3401912</td><td bgcolor='#eeeeec'>PHPExcel_Reader_Excel2007->load(  )</td><td title='C:\Users\operador\wamp\www\hidrocontroll\util\excelMicrosoft\PHPExcel\IOFactory.php' bgcolor='#eeeeec'>..\IOFactory.php<b>:</b>193</td></tr>
</table></font>

 

In line 1263 on Excel2007.php the code represent is:

                        $hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']);

if i ajust the image on template the error ocurred, if i not ajust the same nothing problem occored, but the image will show small

help-me

May 14, 2014 at 8:39 PM
Hi Virgilio, the request found to your problem is that page -----excel2007.php have a error for de images

The code original is:
           foreach ($shapes as $shape) {
        $shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
        $imageData = $shape->xpath('//v:imagedata');

        $imageData = $imageData[0]; 

        $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
        $style = self::toCSSArray( (string)$shape['style'] );
        $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();

                    if (isset($imageData['title'])) {
                    $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );  

        }

        $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
        $hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
        $hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
        $hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
            $hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']);
                   $hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);
          $hfImages[ (string)$shape['id'] ]->setResizeProportional(true);

    }

I changed to:
       $i=0; //************ add  count for images___________

           foreach ($shapes as $shape) {
        $shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
        $imageData = $shape->xpath('//v:imagedata');

        $imageData = $imageData[$i]; // original 0

        $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
        $style = self::toCSSArray( (string)$shape['style'] );
        $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();

                    if (isset($imageData['title'])) {
                    $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );  

        }

        $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
        $hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
        $hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
        $hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
//**************change line
                   $hfImages[ (string)$shape['id'] ]->setOffsetX(isset($style['margin-left'])? $style['margin-left']:0);     end**************************///

          $hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);
          $hfImages[ (string)$shape['id'] ]->setResizeProportional(true);

                 //********************** increment to count    for image                       
                  $i++;
    }

Thus the problem over images in the header is solved.
Cris.