Read template and save fails

Topics: Developer Forum, User Forum
May 23, 2010 at 6:33 AM

I'm reading in an Excel 2007 file and modifying one cell value and saving it just to test the template process in the documentation.  The original Excel file contains a logo and there's some formulas, cell fill colors, currency formatting, etc.  Nothing really out of the ordinary and nothing that I can forsee as unsupported.  So I save the file using the Excel2007 writer as well.  However, when I open it I get an error from Excel stating that the document contains unreadable content and it repairs the file, but it's nothing like the original.  I suspect it has something to do with the logo.  I then proceeded to hand code the entire Excel sheet over again, and I'm nearly 100% done.  However, when I write code to insert my logo, it never shows up.  I am not using an 'X offset' because I want it anchored to the top left corner of the cell.  I have tried a relative and absolute path to my file 'logo.png'.  Can anyone tell me why either:

A) What could be the source of my 'read template and spit back' method issue


B) Why my logo doesn't show up when I create the page myself

I am using IIS 7.0 and I can read and write files to the directory.


P.S. I'll post code if needed, but I thought I'd rather allow people to ask for certain parts if necessary rather than posting a few hundred lines.

May 23, 2010 at 6:00 PM


I got my logo to appear.  I was setting the logo width and height to the same values you get from right-clicking the image in Excel and selecting 'Size and Position'.  As it turns out, my height value was 0.75, and that didn't seem to work with PHPExcel.  Like column widths, I guess it's not a straight translation from Excel to PHPExcel.  I ended up using the height of 75 for my logo (from trial and error) and that seems to work pretty well.  Now, if someone could comment on the import/export template problem, I'd appreciate it.




Aug 17, 2010 at 8:59 AM

Hi Scott,

take a look at my issue "Excel 2007 Reader creates garbage". Maybe this is useful for you.