How to set the cell width in itextsharp pdf creation

后端 未结 4 1651
广开言路
广开言路 2020-12-18 23:35

How can I set cell width and height in itextsharp pdf cell ceration using c#. I just use

cell.width = 200f;

But it should display the error

4条回答
  •  猫巷女王i
    2020-12-18 23:48

    int  count=Gridview1.Columns.Count
    PdfPTable table = new PdfPTable(count);
    float[] columnWidths = new float[count];
    for (int v = 0; v < count; v++)
    {
        if (v == 0) { 
        columnWidths[v] = 10f;
        }
        else if (v == 2)
        {
            columnWidths[v] = 30f;
        }
        else if(v == 3)
        {
            columnWidths[v] = 15f;
        }
        else if(v == 4)
        {
            columnWidths[v] = 18f;
        }
        else if(v == 5|| v == 6|| v == 7)
        {
            columnWidths[v] = 22f;
        }
        else
        {
            columnWidths[v] = 20f;
        }
    }
    
    table.SetWidths(columnWidths);
    

提交回复
热议问题