2016-07-01 72 views
0

我正在嘗試從數據庫導出數據到PDF文件我得到但在PDF中單元格大小不是增加它沒有安排在正確的格式,即單元格是相同的寬度所有colouman我的代碼是這樣的如何使用itext exproting PDF時動態設置單元格寬度Sharp

  pdfTable.DefaultCell.BorderWidth = 1 
      pdfTable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT 

      For Each column As DataColumn In dt.Columns 

       'If column.ColumnName = "INVESTIGATION" Then 
       ' Dim pdfpcell As New PdfPCell() 
       ' pdfpcell.Width = 10.0F 
       'End If 

       pdfTable.AddCell(FormatHeaderPhrase(column.ColumnName)) 
      Next 
      pdfTable.HeaderRows = 1 
      ' this is the end of the table header 
      pdfTable.DefaultCell.BorderWidth = 1 

      For Each row As DataRow In dt.Rows 
       For Each cell As Object In row.ItemArray 
        'assume toString produces valid output 
        pdfTable.AddCell(FormatPhrase(cell.ToString())) 
       Next 
      Next 
      pdfDoc.Add(pdfTable) 

所以我的問題是如何分配動態單元格寬度

回答

0

你必須設置寬度在整個表

這樣

Dim widths As Single() = New Single() {100F, 200F, 300F} 
pdfTable.SetWidths(widths) 

,如果你想一排有你有使用cellspan

cell.Colspan = 3 
+0

更寬的細胞,但列是動態生成的 – Krishnaprasad

相關問題