White font on copy/pasting?

Topics: Developer Forum, User Forum
Jun 22, 2009 at 5:41 PM

I'm running v27960 and am using Excel5. I grab a template file from the filesystem, open it, write some data and output to the browser.

When I download/open the file and copy/paste certain rows that have their font color as black instead of automatic, the font color changes to white in my php-excel document when I paste it. (yup, just like that. black in the source document and white in the destination document). The same data when pasted to a normal excel file seems to copy fine. There's also data in the source file that has font color as automatic that copies over without any issue.

I'm completely baffled by it - am I missing something here?

Jun 23, 2009 at 5:33 PM

Just tried this after changing to the Excel2007 writer and it worked perfectly - seems like an issue with the Excel5 writer.

I also noticed that if I'm filling the background of a cell and copy/pasting it to another cell, the color changes (it changed from turquoise (AFEEEE) to green). Again, this problem did not occur with the Excel2007 writer.

Would anyone know a batch program (hopefully freeware!) to convert Excel 2007 files to the older version - in that case I could skip the Excel5 writer and use the Excel2007 writer.

Developer
Jun 23, 2009 at 8:32 PM

I now notice the behavior you are describing. I think this may not actually be a bug.

When you copy and paste from one Excel document to another, then you will notice similar behavior if the documents are using different themes. But there are "Paste Options", and if you choose the option "Keep source formatting" after pasting, then the original colors are preserved.

With that said, Excel5 writer could perhaps do a better job. There are some built-in color codes in Excel, and if some of those are used, then this could perhaps be avoided for some of the colors: black, white, red, green, blue, yellow, magenta, cyan. Will investigate if we can tweak Excel5 writer a bit and post back here.

Developer
Jun 24, 2009 at 1:05 AM

Can you check if this is fixed with this:
http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10181

Using next source code release:
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Jun 24, 2009 at 2:43 AM

Thanks for the fix koyama - are you referring to v27980 (it's been checked out a couple of days ago though) - that's the latest I'm seeing at the moment.

Developer
Jun 24, 2009 at 1:06 PM

There should now be v28019, I think it may solve at least the black/white copy-paste problems.

Jun 24, 2009 at 10:22 PM
Thanks koyama, will try the latest version and get back to you on
monday - I'm away for the weekend.

On 6/24/09, koyama <notifications@codeplex.com> wrote:
> From: koyama
>
> There should now be v28019, I think it may solve at least the black/white
> copy-paste problems.
>
>
Jul 8, 2009 at 5:40 PM

I finally got around to testing this on the latest version - now the font is a faint gray as against the white earlier.

It is a relief considering that the text is visible, but it still baffles me since the rows I'm pasting are no different from the rest of the rows...any pointers would be really appreciated! Thanks!

Developer
Jul 9, 2009 at 7:12 PM

>> now the font is a faint gray as against the white earlier.

Do you have something I can test with? This time I cannot reproduce the error. Either sample code or you can send me the Excel file (erik at phpexcel dot net).

Jul 11, 2009 at 7:51 PM

The data looks like the screenshot here:

http://img269.imageshack.us/img269/4793/grayscreenshot.jpg

This is the same for the first 5 columns. The rest of the data are in black as expected. This same data copy/pasted onto a new excel file pastes fine.

One additional thing I noticed was that when I copy/paste the header (which has a background of a shade of gray) onto a new excel file, it turns to either white or black depending on the shade of gray I use. I was able to reproduce this in the samples that are present along with the code (the one where an excel file is created with sales details and a nice table along with the phpexcel and ms office logo). If you copy/paste all the content on the sheet onto a new excel workbook, you will notice that the first/second row (which has a shade of gray) will turn white.

Developer
Jul 14, 2009 at 2:02 PM

Hmm... I was not able to reproduce this. Do you have paste options?
http://img257.imageshack.us/img257/5920/microsoftexcelmappe1200.png

Not sure which option you are using when pasting?

Jul 14, 2009 at 3:29 PM

koyama, were you able to reproduce the one in the Tests folder:

When I copy/paste the header (which has a background of a shade of gray) onto a new excel file, it turns to either white or black depending on the shade of gray I use. I was able to reproduce this in the samples that are present along with the code (the one where an excel file is created with sales details and a nice table along with the phpexcel and ms office logo). If you copy/paste all the content on the sheet onto a new excel workbook, you will notice that the first/second row (which has a shade of gray) will turn white.

Developer
Jul 14, 2009 at 8:54 PM

Thanks to your last piece of information I am now able to reproduce the problem with shades of gray.

By default, when I paste, it will use "Match destination formatting" paste option. If I change this to "Keep source formatting", then it pastes in original color. I am wondering whether this is a bug or not.

Jul 15, 2009 at 5:07 PM

koyama, the same gray color when copy/pasted from a regular file pastes fine, whether we paste using source formatting or destination formatting :)

In fact, gray being a transition color from white to black only results in either white or black being shown, other colors have much funnier results :)

Hope you can fix this somehow, even if it's not possible, it's definitely not a deal breaker considering the number of features the library already has - thanks again for all the effort you guys have been putting into this!

Developer
Jul 15, 2009 at 6:13 PM

We will definitely try to do something about this. I believe it has something to do with Excel themes so probably we will have to support that to get this solved. Let's keep this topic alive, I may return to this thread and post when I find out some more about this.

Jul 15, 2009 at 6:16 PM

That's really nice - thanks for the update.

Looking forward to the fix!

Developer
Aug 6, 2009 at 10:34 PM

Well for a start, there is an outline how to fix this issue completely. You may track this work item:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10409