GetPreferredCellSize not working with merge cell

  • 1p
    laggen1p 3 weeks ago

    Dim value As Size
    value = .Sheets(0).GetPreferredCellSize(1, 1)

    My cell (1,1) are merge with cell(1,2)

    .Sheets(0).GetPreferredCellSize(1, 1) only check cell (1,1) and don’t count with the merge cell(1,2)

  • 23p
    GinaDan23p 2 weeks, 6 days ago


    The GetPrerredCellSize method does not have a span option. You could try the GetPreferredColumnWidth method and see if that works for you. For example:

    float size;
    size = fpSpread1.ActiveSheet.GetPreferredColumnWidth(0, true, false, true);

    Thanks, Gina

  • 1p
    laggen1p 2 weeks, 5 days ago

    Hi Gina

    Thanks for your answer.
    The problem with this ae that it’s check all cells in this column, but I only want to check a specific cell.

    when text are not fit in a cell I let it overflow to next line, therefore I have different hight on rows to.

    look attached image.

  • 1p
    laggen1p 2 weeks, 5 days ago

    Upload are not working .png not supported?

  • 23p
    GinaDan23p 2 weeks, 5 days ago


    Try posting the image again. They had to fix an issue with the forum.

    Thanks, Gina

  • 1p
    laggen1p 1 week, 5 days ago

    Here are the image

    You must be logged in to view attched files.
  • 114p
    Sean Lawyer114p 1 week, 4 days ago


    To calculate the preferred size of the span cell, you need to use the lower-level GetPreferredSize method implemented inside the IRenderer for the cell and pass the size of the span cell for the size argument. GetPreferredCellSize ignored span cells and always uses the actual cell size when computing the preferred cell size, but the IRenderer method will use the specified size to compute the preferred size. If the IRenderer wraps the text then GetPreferredSize will return the height required to show the wrapped text in the specified size.Width, otherwise it will return the width required to show the text in one line. To get the IRenderer for the cell, you can use Cell.Renderer.


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to create new topics.