#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

How to copy-paste a table from Excel to WordPress without using plug-ins?

koskila
Reading Time 3 min
Word Count 476 words
Comments 11 comments
Rating 4.8 (4 votes)
View

So, I tried to paste a table from Excel into WordPress, and I failed. Annoying - but not a big problem. I can just paste it into an existing table and it'll "sort itself out", right?

Well, no.

Exporting the Excel sheet as a html page and copy-pasting the table from there didn't work either. Actually, copy-pasting a table just didn't work at all.

So... WordPress is unable to understand HTML tables. Is that really it?

Well, no, again, it's not. It just refuses to understand pasted tables.

Annoyed, I tweeted something like this:

Yes, it took me a couple of months to post my findings into an article. Don't @ me.
Source: https://twitter.com/koskila/status/1329894523137363968

I then decided to figure it out.

Problem

Well, it's pretty simple - WordPress doesn't seem to understand whatever it is that gets copied on the clipboard when you're trying to copy-paste a table from Excel (or almost anything else).

Most of the time, everyone online seems to offer something like a TablePress plug-in. But I don't want another plug-in cluttering my installation - so I wanted to do this with just the out-of-the-box tools available!

Solution

Time needed: 10 minutes.

How to copy-paste a table from Excel to WordPress?

  1. Open your file in Excel

    Hopefully, it'll look somewhat like this:

  2. Save your Excel sheet as a html file

    File > Save as > select ".html" like shown below:

  3. Open the (former) Excel file in a browser

    Simple enough - any decent browser should do, but I'll be using Chrome as an example.
    This image has an empty alt attribute; its file name is image-6.png

  4. Open the html source of the table iframe

    Note, that you definitely do not want the whole file - just the source of the iframe (frame)!

    The screenshot below should clarify this a bit:

    This image has an empty alt attribute; its file name is image-7.png

  5. Copy the html of your table

    Be mindful not to copy the whole document - you only want the

    ...
    !

  6. Paste the HTML in WordPress

    Just jump in and hit CTRL+V (or whatever the shortcut for pasting is on your machine!)

    And you SHOULD have a table. Great!

  7. (OPTIONAL) If the step above didn't work, paste the HTML into a HTML or Classic block and convert it!

    Most of the time, step 6 should've resulted in a table. If that didn't happen, create a new HTML or Classic block instead, and paste the HTML in there.

    Then, hit the "..." at the top and select "Convert to blocks". And THEN you should have a table!

  8. Just some final tweaks to do!

    The styles will probably be all kinds of messed up - but at least you've now got a table to work with!

And you're done!

If you are knowledgeable enough to have a better way to do this, LET ME KNOW, because I'd love to find an easier way. 😁 What a weird gap in functionality, but hey, tables are hard!

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
Willem
2022-02-01 15:48:48)
Hi Annti, until recently I was able to copy (part of) a worksheet into the wordpress editor. with wordpress v5.9 this no longer works. i've found an alternative method: I'm using the the Hueman theme (already for a long time, including the Nimble Builder). I copy and past the excel range into the Nimble Builder editor, which converts the excel range into html format. Copy this html into the wordpress editor and you're done. It takes in fact 1 additional step compared to the old method.
Antti K. Koskela
2022-02-12 23:59:11
Thanks for your comment, Wilem! Yeah, some page builders or themes will have nicer ways to work around this! My installation certainly doesn't, so here we are.. 😅
2022-02-08 10:38:55)
The funny thing is that WordPress used to understand tables quite well (before introducing the new editor and blocks). I remember how I was simply pasting tables with links from excel to WordPress and how beautiful that looked! Good old days! Just one thought on the tweaks: WP uses a </figure> tag around it's tables - that made my life easier when following your ways of working.
Antti K. Koskela
2022-02-12 23:57:59
Hi Hagen, Thanks for your tip! Yeah, not everything is better with Gutenberg... We'll always find ways to cope, but it would certainly be nice if things just worked, right?
2022-02-22 16:06:23)
I hit this problem after I upgraded to WP 5.9 (no problems whatsoever before the upgrade). The solution to save as an HTML file then copy & paste the <table> ... </table> elements seemed to bloat the file enormously. My interim solution (which I'm getting to prefer) is to [1] format the worksheet(s) as you'd like them to appear (e.g. freeze the headings, set page numbers etc) [2] export to PDF file [3] upload that pdf file into WP. This is a particularly good solution for several worksheets as it is scrollable.
Antti K. Koskela
2022-03-19 22:15:56
Hi Alan, Fair point - WordPress HTML can be bloated in itself, but copying the structure Excel generates does make the issue a thousand times worse! PDF export and attachment is definitely a fine workaround for a lot of situations :)
2022-05-13 19:36:52)
Hi, further to this I now use the following method: 1) format your data as required, with the first row as the heading row. 2) select the data 3) run the following macro which converts the selected cells to HTML and places onto the clipboard. 4) Paste into a Custom HTML block (part of the "Legacy Widgets") Option Explicit Sub TableToHTML() Dim lRowPtr As Long Dim lColPtr As Long Dim rData As Range Dim sCurTag1 As String Dim sCurTag2 As String Dim sCurValue As String Dim sHTML As String Application.StatusBar = False sCurTag1 = "<th>" sCurTag2 = "</th>" sHTML = "<table> " Set rData = Application.Selection If rData.Cells.Count < 2 Then   MsgBox "Please select area to be copied to clipboard"   Exit Sub End If For lRowPtr = 0 To rData.Rows.Count - 1   sHTML = sHTML & "<tr>"   For lColPtr = 0 To rData.Columns.Count - 1     sCurValue = CStr(rData.Resize(1, 1).Offset(lRowPtr, lColPtr).Text)     sHTML = sHTML & sCurTag1 & HTMLSpecialChars(sCurValue) & sCurTag2   Next lColPtr   sHTML = sHTML & "</tr>" & vbCrLf   sCurTag1 = "<td>"   sCurTag2 = "</td>" Next lRowPtr sHTML = sHTML & "</table>" Clipboard sHTML Application.StatusBar = Format(Now(), "hh:mm:ss") & ": HTML table copied to clipboard" End Sub Private Function Clipboard$(Optional s$) 'https://stackoverflow.com/questions/14219455/excel-vba-code-to-copy-a-specific-string-to-clipboard   Dim v: v = s 'Cast to variant for 64-bit VBA support   With CreateObject("htmlfile")   With .parentWindow.clipboardData     Select Case True       Case Len(s): .setData "text", v       Case Else:  Clipboard = .GetData("text")     End Select   End With   End With End Function Private Function HTMLSpecialChars(ByVal InputString As String) As String Dim lPtr As Long Dim sResult As String Dim vaFromString As Variant Dim vaToString As Variant vaFromString = Array("&", Chr(34), "'", "<", ">") vaToString = Array("&amp;", "&quot;", "&apos;", "&lt;", "&gt;") sResult = InputString For lPtr = LBound(vaFromString) To UBound(vaFromString)   sResult = Replace(sResult, vaFromString(lPtr), vaToString(lPtr)) Next lPtr HTMLSpecialChars = sResult End Function
2022-06-11 21:00:27
Hi Alan, Thanks for sharing!
2022-07-12 14:24:12)
Thank you very much! It worked fine. Greetings, Stef
Antti K. Koskela
2022-07-13 12:12:25
Thanks for the kind comment, Stef! Happy to be of help :)
Obraz na Sprzedaż
2023-09-18 02:45:38)
Thank you for the valuable information in this post. It has provided me with new insights and has been instrumental in helping me solve a problem. I appreciate your efforts!
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-19T05:06:17Z