Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: Excel graphic problem

$
0
0

Hi.

I have a problem when I open an excel file with a graphic created with excel, then modify it and finally save it to disk.

When I try to open de updated file using excel, the file is short and the graphics are not comleted, the doesn't have the background, the border and so on. I got the error: part of the file cannot be read Do ypu wish and repair this file?

 

Is necesary to say that all the text into the file is OK but the original graphic is not the same. I have not changed by program the original graphic.

Simple excel files without graphics works right

The code I am using is the following:

require_once 'Classes/PHPExcel/IOFactory.php';
require_once 'Classes/PHPExcel.php';


$inputFileType = 'Excel2007';
$inputFileName = 'File.xlsx';
$generatedFile = 'zzz.xlsx';

try {

    // Create a new Reader of the type defined in $inputFileType
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    $objReader->setIncludeCharts(TRUE);

    //  Load $inputFileName to a PHPExcel Object
    $objPHPExcel = $objReader->load($inputFileName);

    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);
    $objPHPExcel->getActiveSheet()->setCellValue('C13', '2');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
    $objWriter->setIncludeCharts(TRUE);
   
    if (file_exists('excel/' . $generatedFile )) {
        unlink('excel/' . $generatedFile);
    }

    $objWriter->save("excel/".$generatedFile);
   
} catch (Exception $e) {
    die('Error on file: ' . $e->getMessage());
}

Any Ideas? I need this urgent,

Thank you in advance.


Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>