i have a string that already has a newline char on it, but when I set a table cell value with the string, the new line does not exist, here’s the code for setting the value.
Private Sub setCellValue(ByRef oCell As Cell, ByVal sValue As String)
oCell.RemoveAllChildren()
oCell.CellFormat.WrapText = True
oCell.CellFormat.FitText = True
Dim oText As New Paragraph(oCell.Document)
oCell.AppendChild(oText)
Dim oRun As New Run(oCell.Document, sValue)
oRun.Font.Name = m_FontName
oRun.Font.Size = m_FontSize
oText.AppendChild(oRun)
End Sub
Hi
Thanks for your inquiry. You should use DocumentBuilder in this case. Please see the following code:
Private Sub setCellValue(ByRef oCell As Cell, ByVal sValue As String)
oCell.RemoveAllChildren()
oCell.CellFormat.WrapText = True
oCell.CellFormat.FitText = True
oCell.EnsureMinimum()
'Create DocumentBuilder
Dim builder As DocumentBuilder = New DocumentBuilder(oCell.Document)
'move DocumentBuilder cursor into the cell
builder.MoveTo(oCell.FirstParagraph)
'set formating
builder.Font.Name = m_FontName
builder.Font.Size = m_FontSize
'insert text
builder.Write(sValue)
End Sub