none
Pasting Table from Excel in Word merges the cells RRS feed

  • Question

  • Hi,

    I am pasting excel data into Word as WordTable.

    Word seems to automatically merge cells if excel data/text overlaps two cells
    e.g text in 2nd cell of 1st Row is exceeding cell width and overlaps 3rd cell

    

    Now, upon pasting this in Word automatically merges the cell(1,2) and cell(1,3) in resultant Table.

    My requirement is to get table without merged cells.

    I have tried all 'Paste Special' options but nothing seems to produce Table without merged cells.

    Is there any way of getting Word Table in this case without merged cell?

    Rahul

    Thursday, November 20, 2014 12:30 PM

All replies

  • If you need to Paste Links, I don't know of a way.

    But if you just need to paste a copy and it doesn't have to look too much like the original, one approach would be to use the Excel Home->Alignment->Wrap Text button to wrap long text, then Copy->Paste, then Undo the change in Excel. 

    That seems simpler and more reliable than
     a. Copy in Excel
     b. In Word, Paste Special->Unformatted text
     c. Select the text and use Insert->Table->Convert text to Table (OK as long as there are no tabs in the Excel data).

    BTW, this doesn't seem much like a "Developer" question!


    Peter Jamieson


    Thursday, November 20, 2014 5:26 PM
  • Thanks Fei

    I am aware of Excel- Wrap text but my requirement is to import excel data in word without changing Excel setting.

    Actually I have a word addin which can create document containing Embedded OLEWordTable

    And i need to programmatically update word table  to have Excel data and maintain link for any updates.

    I was able to achieve most of scenarios work, it's only in case of overlapping cells that i am facing issue.
    My client doesn't want the automatic merging feature. So wanted to confirm in case there is any way to import data without merging but paste as link.

    Custom solution of iterating the table to find and resolve merges are cell level might get messy.

    Rahul

    Friday, November 21, 2014 6:53 AM
  • Any automatic updates are always likely to overwrite at least some of the formatting that the user, or code, has applied in Word.

    My understanding is that you could use a LINK field with the Unformatted text option to avoid the cell merging problem. But if someone (either the user, or some code) needs to apply formatting to the resulting table, the question is "who does that when the source data updates and any user/code-formatting is lost" ? From a programming perspective, I think you need a "LINK field update" event, but I do not think there is one, or an event that you could use instead.

    The only possibility I can think of right now is that if the users are using Word 2013, and you can ensure that the linked object (or e.g. a LINK field) is inside a rich text content control and that control is mapped to a Custom XML part, then you might be able to use the events associated with the custom XML Part to achieve what you need.

    Definitley a "Developer question" !



    Peter Jamieson

    Monday, November 24, 2014 6:41 PM
  • Thanks Peter for the explanation.

    In my case, the issue is not while updating the Link as i need manual update.

    Issue is upon insertion itself. I am using PasteExcelTable API  (which inserts LINK field) and have explored all PasteSpecial options but no option is there which won't merge the overlapping cells of Excel.

    I tried Paste Special -> Link as /RTF/Unformatted/HTML .. , but all seems to merge the overlapping excel cells.

    My client uses Word 2010. Did you try pasting LINK field as Unformatted Text ? It still results in merged cell only.

    Rahul

    Tuesday, November 25, 2014 7:04 AM
  • You are right: when I paste special and LINK as unformatted text, each cell's content is separated by a tab. So in principle, you get to be able to reformat the columns. But since you can't then select that and convert to a table without UNLINKing , I don't think you could actually do your own cell formatting.

    Peter Jamieson

    Wednesday, November 26, 2014 9:48 AM