none
Cells in table configuration C# RRS feed

  • Question

  • Hi,

    I've put an image to a cell, but between border and image is an empty space. Is it possible to remove it ?I wanted to set padding setting of a cell, but it does not work. I have really no idea how to do it ?

    Additionally I have another question. Is it possible to check programmactically if the text in a cell is wrapped ? I do a table and I have to decide about its size which depends dynamically on a length of a text.

    I wanted to add images to my post, but it's not possible because

    Cheers.

    P.S. I can't add images, I don't know how to verify my account. I did it by email but no change.

    Saturday, December 15, 2012 7:01 PM

Answers

  • Hi Zordon157,

    Sorry for that I've misunderstood your intention, since I haven't noticed it's a table in a Word document.

    For your 2nd problem, you can have a try on Table.AutoFitBehavior Method. To meet your request, you can try

    Table.AutoFitBehavior(Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent);

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 20, 2012 7:48 AM
    Moderator

All replies

  • Hi Zordon157,

    Thank you for posting in the MSDN Forum.

    Could you please show me the code that puts image into a cell? It will be helpful for me to solve your issue.

    Besides, in order to detect whether a cell has WrapText, you can check the value of Range.WrapText property.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 17, 2012 9:46 AM
    Moderator
  • Thank for reply.

    I've added picture to cell using code:

    currentCell.Range.InlineShapes.AddPicture(ImageLink);

    I've solved problem with images. To remove white padding between cell's border and image:

    currentCell.Range.InlineShapes[1].ConvertToShape();
    currentCell.Range.ShapeRange.WrapFormat.Type = WdWrapType.wdWrapSquare;

    But I've still a problem with detecting if text in a cell is wrapped like this:

    __________________________________________________

    aaaaaaaaaaaaaaaaaaa|

    bbbbbb                          |

    ----------------------------------------------------------------

    where text: 'aaaaaaaaaaaaaaaaaaabbbb' is in one cell, and is divided to two lines because its too long for this cell's size.

    I want to dectect it and change Cell size programmatically to fit the whole text in one line.

    I don't have Range.WrapText property in a Word library ;/

    Best regards.


    • Edited by Zordon157 Wednesday, December 19, 2012 5:24 PM
    Wednesday, December 19, 2012 5:22 PM
  • Hi Zordon157,

    Sorry for that I've misunderstood your intention, since I haven't noticed it's a table in a Word document.

    For your 2nd problem, you can have a try on Table.AutoFitBehavior Method. To meet your request, you can try

    Table.AutoFitBehavior(Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent);

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 20, 2012 7:48 AM
    Moderator