#27909 closed defect (bug) (fixed)
Pasting Tables from Excel Strips Tables
Reported by: | kirasong | Owned by: | |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | TinyMCE | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Prior to 3.9, one could copy/paste cells directly from Excel into TinyMCE (either directly or with Paste from Word).
Now, after paste, it inserts the numbers, followed by an È, stripping all table HTML.
Reproduced on Mac Excel 2011:
- Open Excel
- Enter a few numbers into two lines
- Copy Cells
- Paste into WordPress Visual Editor
Sample pasted HTML after pasting into 3.8.x, in case it helps:
<table width="260" border="0" cellspacing="0" cellpadding="0"><!--StartFragment--> <colgroup><col span="4" width="65" /> </colgroup> <tbody> <tr> <td align="right" width="65" height="15">1</td> <td align="right" width="65">5</td> <td align="right" width="65">2</td> <td align="right" width="65">5</td> </tr> <tr> <td align="right" height="15">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> <!--EndFragment--></tbody> </table>
Sample screenshots attached.
Attachments (5)
Change History (49)
#2
@
10 years ago
Related Forum Post: http://wordpress.org/support/topic/cant-paste-excel-graphs-in-v-39?replies=11
Note: I can't get graphs to paste in 3.8 either, so I suspect their later note about them not working previously is correct.
#6
@
10 years ago
Testing with Office 365 Excel (2013+) on Windows 8.1, cannot reproduce (data is pasted as a table with the corresponding html and necessary formatting).
Testing with the Excel Online web-app, was able to reproduce: data pasted as plain text with spaces between cells and line breaks between rows.
This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.
10 years ago
#8
@
10 years ago
- Milestone changed from 3.9.1 to 3.9.2
Looks like this will need to be reported upstream.
#9
@
10 years ago
I'm not convinced this is upstream, at least with regards to TinyMCE proper.
The same paste works fine here: http://www.tinymce.com/tryit/basic.php
So it's either PasteFromWord, or us stripping too much, somehow. I haven't tested disabling PasteFromWord as of yet.
Edit: I may have been wrong about it working in the TinyMCE test above. It did work when the bug was reported, but does not today. An update perhaps, or my mistake reproducing? Either way, yes, probably upstream at this point.
#10
follow-up:
↓ 12
@
10 years ago
This is definitely from the 'paste' plugin, or some way we're using those filters.
With the 'paste' plugin disabled, the paste works as expected.
#11
@
10 years ago
More details: Can reproduce in Chrome or Safari on Mac, but works fine in Firefox.
#12
in reply to:
↑ 10
;
follow-up:
↓ 13
@
10 years ago
Some testing with Excel 2013 Desktop App, Excel Online and Windows 8.1
Replying to celloexpressions:
Testing with Office 365 Excel (2013+) on Windows 8.1, cannot reproduce (data is pasted as a table with the corresponding html and necessary formatting).
Same, cannot reproduce with the same config, works as expected with a new post in WordPress or the TinyMCE demo.
Replying to celloexpressions:
Testing with the Excel Online web-app, was able to reproduce: data pasted as plain text with spaces between cells and line breaks between rows.
This is expected behaviour, when coping a range of cells (Copy/CTRL-C) the clipboard does NOT receive any HTML formatting in the clipboard from Chrome or IE 11 (There appears to be some extra formatting and/or interpretations of that formatting when pasting the contents back into the online spreadsheet to interpret each 'tab' as an individual cell)
1 5 2 5 8 2 1 3
Replying to DH-Shredder:
This is definitely from the 'paste' plugin, or some way we're using those filters.
With the 'paste' plugin disabled, the paste works as expected.
How do I disable just the 'paste' plugin? I'd like to see what results I get, I expect the 'full html source per below'.
Replying to DH-Shredder:
More details: Can reproduce in Chrome or Safari on Mac, but works fine in Firefox.
I am not sure how or if you can view the raw HTML source of the clipboard on a Mac but if you can comparing it to what I have in this gist would help find what element/character/string is causing the issue with TinyMCE 'paste' plugin.
The HTML source of the clipboard from Excel 2013 before being stripped by TinyMCE 'paste' plugin:
(Complete HTML source including namespace and styles here)
<table border=0 cellpadding=0 cellspacing=0 width=256 style='border-collapse: collapse;width:192pt'> <!--StartFragment--> <col width=64 span=4 style='width:48pt'> <tr height=20 style='height:15.0pt'> <td height=20 align=right width=64 style='height:15.0pt;width:48pt'>1</td> <td align=right width=64 style='width:48pt'>5</td> <td align=right width=64 style='width:48pt'>2</td> <td align=right width=64 style='width:48pt'>5</td> </tr> <tr height=20 style='height:15.0pt'> <td height=20 align=right style='height:15.0pt'>8</td> <td align=right>2</td> <td align=right>1</td> <td align=right>3</td> </tr> <!--EndFragment--> </table>
I suspect there are a few differences in the clipboard content between Mac Excel 2011 and Windows Excel 2013.
I also added the HTML source for the same table from Word 2013 in the gist, and as you can see there is quite a big difference yet both work as expected for me and a copy of the Excel 2013 document I used here.
#13
in reply to:
↑ 12
;
follow-up:
↓ 14
@
10 years ago
Replying to natweb:
How do I disable just the 'paste' plugin? I'd like to see what results I get, I expect the 'full html source per below'.
I disabled it directly from within wp-includes/class-wp-editor.php
, but you can also filter the array in tiny_mce_plugins
.
I am not sure how or if you can view the raw HTML source of the clipboard on a Mac but if you can comparing it to what I have in this gist would help find what element/character/string is causing the issue with TinyMCE 'paste' plugin.
Sure, here you go, using your Excel file: https://gist.github.com/getsource/11197359
#14
in reply to:
↑ 13
@
10 years ago
Replying to DH-Shredder:
Replying to netweb:
I am not sure how or if you can view the raw HTML source of the clipboard on a Mac but if you can comparing it to what I have in this gist would help find what element/character/string is causing the issue with TinyMCE 'paste' plugin.
Sure, here you go, using your Excel file: https://gist.github.com/getsource/11197359
Using my Excel file did it work when pasting into a new post?
Can you post the HTML source of your Excel file so we can check if the 'native' generated source is different.
Replying to DH-Shredder:
More details: Can reproduce in Chrome or Safari on Mac, but works fine in Firefox.
Is it the same result with each browser when pasting into the TinyMCE demo? http://www.tinymce.com/tryit/basic.php
Replying to DH-Shredder:
Replying to natweb:
How do I disable just the 'paste' plugin? I'd like to see what results I get, I expect the 'full html source per below'.
I disabled it directly from within
wp-includes/class-wp-editor.php
, but you can also filter the array intiny_mce_plugins
.
I just disabled the 'paste' plugin the same way as above and when pasting from my Excel file and per these results we want to keep the 'paste' plugin enabled to strip the extra formatting but find out what is different and why it only works with Firefox on a Mac.
excel-27909-no-paste-plugin.html :
<table style="border-collapse: collapse; width: 192pt;" border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup><col style="width: 48pt;" span="4" width="64" /> </colgroup> <tbody> <tr style="height: 15.0pt;"> <td style="height: 15.0pt; width: 48pt;" align="right" width="64" height="20">1</td> <td style="width: 48pt;" align="right" width="64">5</td> <td style="width: 48pt;" align="right" width="64">2</td> <td style="width: 48pt;" align="right" width="64">5</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
excel-27909-with-paste-plugin.html:
<table border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup><col span="4" width="64" /> </colgroup> <tbody> <tr> <td align="right" width="64" height="20">1</td> <td align="right" width="64">5</td> <td align="right" width="64">2</td> <td align="right" width="64">5</td> </tr> <tr> <td align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
#15
follow-up:
↓ 16
@
10 years ago
Resolved this issue in TinyMCE. The code did only handle the Windows clipboard case where the <!--StartFragment--> and <!--EndFragment--> is places around the body of clipboard contents. On Mac when pasting tables it's added inside the table to the start of the table gets chopped of.
https://github.com/tinymce/tinymce/commit/1b7c41cd7bf61b9709145d9e15f8f8297bbb77d7
#16
in reply to:
↑ 15
@
10 years ago
- Keywords needs-testing added
Replying to spocke:
Resolved this issue in TinyMCE. The code did only handle the Windows clipboard case where the <!--StartFragment--> and <!--EndFragment--> is places around the body of clipboard contents. On Mac when pasting tables it's added inside the table to the start of the table gets chopped of.
https://github.com/tinymce/tinymce/commit/1b7c41cd7bf61b9709145d9e15f8f8297bbb77d7
Thanks :)
Attached patch 27909.patch needs testing, can be tested with define( 'SCRIPT_DEBUG', true );
in wp-config
Minified file paste.min.js
also needed (not part of the build tools) and/or any further upstream 'paste' updates.
#17
follow-up:
↓ 18
@
10 years ago
Lets add this to trunk for easier testing. Apart from the pasting from Excel on Mac fix, there is another border case fix described in https://core.trac.wordpress.org/ticket/27771#comment:7.
Upstream changesets: https://github.com/tinymce/tinymce/commit/1b7c41cd7bf61b9709145d9e15f8f8297bbb77d7 and https://github.com/tinymce/tinymce/commit/7998b8025d2cd5d66853aa33680d0ec2a0f7807b.
#18
in reply to:
↑ 17
;
follow-up:
↓ 20
@
10 years ago
Replying to azaozz:
Lets add this to trunk for easier testing. Apart from the pasting from Excel on Mac fix, there is another border case fix described in https://core.trac.wordpress.org/ticket/27771#comment:7.
Cool.... Here you go... 27909.2.patch:
- Includes the pasting from Excel for Mac fix via 1b7c41cd7b
- Includes the TOC fix not included in #27771 via 7998b8025d
- Includes edge case in #27771#comment:7, this has NOT been merged upstream yet via tinymce/pull/362
#19
@
10 years ago
In [28192]:
TinyMCE: update the 'paste' plugin to the latest dev. version. Included changes: https://github.com/tinymce/tinymce/commit/1b7c41cd7bf61b9709145d9e15f8f8297bbb77d7 and https://github.com/tinymce/tinymce/commit/7998b8025d2cd5d66853aa33680d0ec2a0f7807b. See #27909, for trunk.
#20
in reply to:
↑ 18
;
follow-up:
↓ 21
@
10 years ago
Replying to netweb:
- Includes edge case in #27771#comment:7, this has NOT been merged upstream yet.
Lets keep it to "official" upstream changes, that might get changed on merge, etc. :)
#21
in reply to:
↑ 20
;
follow-up:
↓ 22
@
10 years ago
Replying to azaozz:
Replying to netweb:
- Includes edge case in #27771#comment:7, this has NOT been merged upstream yet.
Lets keep it to "official" upstream changes, that might get changed on merge, etc. :)
This has now been merged upstream via 753635b
#24
follow-up:
↓ 25
@
10 years ago
Hi there, not sure if it has been mentioned but I apologize if it has. I've discovered that in 3.9, when you paste with your mouse you don't get the desired results but pasting with keyboard (cntrl v) gives you the right results. I tested this in 3.8 and this didn't happen. I was getting the same result when doing it with either keyboard or mouse in 3.8.
Thanks
#25
in reply to:
↑ 24
@
10 years ago
Replying to husdaman:
Hi there, not sure if it has been mentioned but I apologize if it has. I've discovered that in 3.9, when you paste with your mouse you don't get the desired results but pasting with keyboard (cntrl v) gives you the right results. I tested this in 3.8 and this didn't happen. I was getting the same result when doing it with either keyboard or mouse in 3.8.
Thanks
Which program are you pasting from Word or Excel and which version 2007, 2008, 2010, 2013, Office 365?
Using a Mac or Windows?
What browser are you pasting into? Safari, Chrome, Internet Explorer, Firefox, Opera?
Have you tried pasting into a different browser and are the results the same?
#26
follow-up:
↓ 30
@
10 years ago
I have found that...
Pasting from Excel 2011 on Mac via Safari or Chrome to WordPress removes all table tags
Pasting a copy of any html rendered table on a webpage via Safari or Chrome to WordPress retains/creates inline styles but displays them on the frontend (whilst it renders ok in the editor).
[first trac note]
#27
follow-up:
↓ 28
@
10 years ago
also I have a problem with pasting of any kind from a webpage
<p style="color: #111111;">test</p>
prints
#111111;">test
to screen
#28
in reply to:
↑ 27
;
follow-up:
↓ 29
@
10 years ago
Replying to TheCellarRoom:
Pasting from Excel 2011 on Mac via Safari or Chrome to WordPress removes all table tags
Are you testing in WordPress 3.9 or in trunk? This should be fixed in trunk with [28192].
<p style="color: #111111;">test</p>
prints#111111;">test
Couldn't get this to break in any browser. Could you give some more details on how to reproduce.
#29
in reply to:
↑ 28
@
10 years ago
Replying to azaozz:
re: first point was using 3.9. copied files from trunk, but error still exists. I attempted to use the patches but both failed to work.
forget the second point, me being silly. i have a plugin that turns #tags into links to twitter searches. WordPress 3.9 is now keeping the style from copied text and is breaking with the style being converted into a link and rendering the excess. - although i'll need to be able to stop this going forward.
#30
in reply to:
↑ 26
;
follow-up:
↓ 31
@
10 years ago
Replying to TheCellarRoom:
I have found that...
Pasting from Excel 2011 on Mac via Safari or Chrome to WordPress removes all table tags
Pasting a copy of any html rendered table on a webpage via Safari or Chrome to WordPress retains/creates inline styles but displays them on the frontend (whilst it renders ok in the editor).
[first trac note]
Same on Windows with Firefox and Word/Excel 2010, no table past, only clean text will pass.
#31
in reply to:
↑ 30
@
10 years ago
Replying to maurizio04:
Same on Windows with Firefox and Word/Excel 2010, no table past, only clean text will pass.
The fix in this ticket r28192 was specifically for pasting from Excel on a Mac, I have not lost table formatting(1) when pasting from Excel 2013 on Windows.
Trying to find a way to test this, anyone else have Excel 2010 on a Windows box?
(1) Note: I haven't lost formatting, it might not be the correct table formatting, but it is NOT plain text.
#32
follow-up:
↓ 33
@
10 years ago
All the browsers via Excel 2013 using this Excel file here on Windows 8.1 x64
Clipboard HTML Fragment
<body link="#0563C1" vlink="#954F72"> <table border=0 cellpadding=0 cellspacing=0 width=256 style='border-collapse:collapse;width:192pt'> <!--StartFragment--> <col width=64 span=4 style='width:48pt'> <tr height=20 style='height:15.0pt'> <td height=20 align=right width=64 style='height:15.0pt;width:48pt'>1</td> <td align=right width=64 style='width:48pt'>5</td> <td align=right width=64 style='width:48pt'>2</td> <td align=right width=64 style='width:48pt'>5</td> </tr> <tr height=20 style='height:15.0pt'> <td height=20 align=right style='height:15.0pt'>8</td> <td align=right>2</td> <td align=right>1</td> <td align=right>3</td> </tr> <!--EndFragment--> </table> </body>
Google Chrome 34
- Everything looks fine here
<table border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup> <col span="4" width="64" /> </colgroup> <tbody> <tr> <td align="right" width="64" height="20">1</td> <td align="right" width="64">5</td> <td align="right" width="64">2</td> <td align="right" width="64">5</td> </tr> <tr> <td align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
Internet Explorer 11
- Note the
È
at the top of the code - Styles are not removed
È <table style="width: 192pt; border-collapse: collapse;" border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup> <col style="width: 48pt;" span="4" width="64" /> </colgroup> <tbody> <tr style="height: 15pt;"> <td style="border: 0px black; width: 48pt; height: 15pt; background-color: transparent;" align="right" width="64" height="20"> <span style="font-family: Calibri; font-size: medium;">1</span> </td> <td style="border: 0px black; width: 48pt; background-color: transparent;" align="right" width="64"> <span style="font-family: Calibri; font-size: medium;">5</span> </td> <td style="border: 0px black; width: 48pt; background-color: transparent;" align="right" width="64"> <span style="font-family: Calibri; font-size: medium;">2</span> </td> <td style="border: 0px black; width: 48pt; background-color: transparent;" align="right" width="64"> <span style="font-family: Calibri; font-size: medium;">5</span> </td> </tr> <tr style="height: 15pt;"> <td style="border: 0px black; height: 15pt; background-color: transparent;" align="right" height="20"> <span style="font-family: Calibri; font-size: medium;">8</span> </td> <td style="border: 0px black; background-color: transparent;" align="right"> <span style="font-family: Calibri; font-size: medium;">2</span> </td> <td style="border: 0px black; background-color: transparent;" align="right"> <span style="font-family: Calibri; font-size: medium;">1</span> </td> <td style="border: 0px black; background-color: transparent;" align="right"> <span style="font-family: Calibri; font-size: medium;">3</span> </td> </tr> </tbody> </table>
Firefox 29
- Styles partially removed
<table border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup> <col style="width: 48pt;" span="4" width="64" /> </colgroup> <tbody> <tr style="height: 15.0pt;"> <td style="height: 15.0pt; width: 48pt;" align="right" width="64" height="20">1</td> <td style="width: 48pt;" align="right" width="64">5</td> <td style="width: 48pt;" align="right" width="64">2</td> <td style="width: 48pt;" align="right" width="64">5</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
Opera 12.17
- Styles not removed
<table style="border-collapse: collapse; width: 192pt;" border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup> </colgroup> <tbody> <tr style="height: 15.0pt;"> <td style="height: 15.0pt; width: 48pt;" align="right" width="64" height="20">1</td> <td style="width: 48pt;" align="right" width="64">5</td> <td style="width: 48pt;" align="right" width="64">2</td> <td style="width: 48pt;" align="right" width="64">5</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
Opera 22.0.1471.8
- Everything looks fine here
<table border="0" width="256" cellspacing="0" cellpadding="0"> <colgroup> <col span="4" width="64" /> </colgroup> <tbody> <tr> <td align="right" width="64" height="20">1</td> <td align="right" width="64">5</td> <td align="right" width="64">2</td> <td align="right" width="64">5</td> </tr> <tr> <td align="right" height="20">8</td> <td align="right">2</td> <td align="right">1</td> <td align="right">3</td> </tr> </tbody> </table>
#33
in reply to:
↑ 32
@
10 years ago
Replying to netweb:
All the browsers via Excel 2013 using this Excel file on Windows 8.1 x64
Clipboard HTML Fragment
Well it looks like on Windows Word /Excel 2010 are the version that will not paste table at all.. :-(
#34
@
10 years ago
Don't know whether this will be of any use to anyone still trying to sort this out, but here's what I just found out.
My situation is that I just need to update some pre-existing tables, so I went into text view, deleted the old table contents just leaving the table tags, back into visual, paste the new table contents using ctrl-v and got a table (no borders, but I can live with that for now)
I am using exel 2010 and windows 7
#35
@
10 years ago
- Milestone changed from 3.9.2 to 4.0
- Resolution set to fixed
- Status changed from new to closed
All of these fixes are in TinyMCE 4.1.2 (currently in trunk) and seem to work well.
#36
follow-up:
↓ 37
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
This is still broken. I'm using wordpress 3.9.1, and pasting tables from Excel 2011 on the Mac.
All formatting is stripped.
This is really a mess and is creating problems already. This used to work through WP 3.8.3.
One can trick wordpress by first pasting the selected cells into MS Word, and then pasting into wordpress. The tables then paste properly.
This is less than ideal, however.
#37
in reply to:
↑ 36
@
10 years ago
- Resolution set to fixed
- Status changed from reopened to closed
Replying to daveslc:
This is still broken. I'm using wordpress 3.9.1
Can you please test again on the current trunk or beta 4 of WordPress 4.0? I just tested this and it was indeed broken in 3.9, but fixed in trunk.
#38
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Additionally, I have found that hitting the back button when editing a post that uses formatted text, or when updating photos and going back to the post, that formatting is stripped.
My guess is that it's related to the excel bug.
#39
@
10 years ago
- Resolution set to fixed
- Status changed from reopened to closed
You mean the browser's Back button? Then you navigate away from the page without saving, nothing to do with pasting into the editor.
#40
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
The excel pasting bug is not fixed in 3.9.2. Tables pasted from excel are stripped of all formatting.
#41
@
10 years ago
- Resolution set to fixed
- Status changed from reopened to closed
This is marked as fixed in 4.0, not 3.9.2. Please test using 4.0 (either trunk or RC) and reopen if it is a problem there.
#42
follow-up:
↓ 43
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I have just upgraded the first of my sites to 4.0 and have found this problem is still occurring, but only when I paste a table into a brand new post. If I type so much as a single character into the post first then the table will paste (reasonably) correctly. If I then delete everything from that post, or discard and then create a new post, the table will still paste without losing its structure. However on logging out and logging back in, the paste fails with a new post.
The same is true of pasting from a word document. I am still using Word/Excel 2010 on Windows 7 - Firefox
#43
in reply to:
↑ 42
@
10 years ago
- Keywords needs-patch needs-testing removed
- Resolution set to fixed
- Status changed from reopened to closed
Replying to FreestyleMD:
The 'paste' plugin was updated few times since this. Pasting from Excel seems to work well here in trunk. Can you reproduce this in the TinyMCE demo? If yes, could you open a ticket with examples at their bug tracker and perhaps a new ticket for 4.1.
#44
@
9 years ago
I believe this fix has regressed in at least some browsers. See also: #35397
In WP 4.4.2, Windows 10 (and a client has reported same issue in Win 7), Chrome (48.0.X), Excel 2007 the table formatting is completely removed when pasting directly into the editor from Excel with Paste as Plain Text turned off.
The expected behavior—relatively clean HTML table code—is correctly pasted when using Firefox (44.0.2). The same data also correctly pasted when copied from Google Sheets in Chrome.
Screenshot: https://cloudup.com/cgwaWqvohzf
3.8.x: Tables Pasted, but Post not Saved