0

enter image description hereI am trying to create a table using iTextSharp library in C#. What I want to set the width of the cell in the table.

I am using following code:

PdfPTable Ptbl_DetailsPerformance = new PdfPTable(7);
Ptbl_DetailsPerformance.SetWidths(new int[7] { 20, 8, 8, 8, 8, 8, 1 });

PdfPCell cellValue = new PdfPCell(); 

Now I want to dynamically set the width of cell but get error that "Width can't be set."

What should I do? Please help..

4

1 回答 1

0

好吧,您不能在单元格级别设置宽度,只能在表格中设置(宽度在 PdfPCell 级别没有设置器,如果我没记错的话)。

在不了解您的问题的情况下很难帮助您。您可以在 ITextSharp 中使用 colspan ,或者在表格级别计算您的“动态宽度”,但是......

你有什么需要?

编辑:itextsharp 2.050727 源(矩形类:PdfPCell 继承自矩形,并且不覆盖宽度)

public virtual float Width
    {
      get
      {
        return this.urx - this.llx;
      }
      set
      {
        throw new InvalidOperationException(MessageLocalization.GetComposedMessage("the.width.cannot.be.set"));
      }
    }
于 2012-04-06T11:59:48.237 回答