Question

I have the following code, which is being run in CodeIgniter.

The template file aol.xlsx contains a chart in Excel 2010. When the file saved to aoltest.xlsx the chart has been removed by Excel but all other data is intact. On opening the file aoltest.xlsx Excel gives the error

Removed Part: /xl/drawings/drawing1.xml part. (Drawing shape)

I am running WAMP on windows 8

Here is my code.

        $this->load->library('excel');
        $fileType = 'Excel2007';
        $fileName = 'D:/excelfiles/aol.xlsx';
        $fileName2 = 'D:/excelfiles/aoltest.xlsx';

        // Read the file
        $objReader = PHPExcel_IOFactory::createReader($fileType);
        $objReader->setIncludeCharts(TRUE);
        $objPHPExcel = $objReader->load($fileName);


        // Write the file
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
        $objWriter->setIncludeCharts(TRUE);
        $objWriter->save($fileName2);

This is my data table

    201401  201402  201403  201404  201405  201406  201407
a   74      42      12      98      64      37      74
b   16      19      100     28      85      40      1
C   66      13      9       41      92      90      38
D   44      35      42      38      81      38      43

****Update*****

By changing the column labels above to strings rather than numeric values everything worked like a charm. The reason for the YYYYWW representation is important however and so a fix to allow integers as column headers would be very much appreciated or documented that you should not use integers (May be it is already documented and I just haven't seen it).


I have seen a lot of other people complaining about this on many forums and in not a single instance have I found anyone who reports that the issue is fixed. Can anyone confirm that they got this to work and in which case what platform / OS were you using?

Was it helpful?

Solution

The issue was being caused because PHPExcel does not support chart column labels of type Integer. After changing the column labels to Strings in my Excel template everything worked fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top