Source: huide Control Network
Using the documentbuilder. inserthtml method, aspose. Words can be inserted into a document in an HTML source. The input can be a complete HTML page or a part of the clip. In this way, we can use table elements such as <Table>, <tr>, and <TD> to insert tables for our documents.
C #
1234567891011121314151617 |
Document doc =
new Document(); DocumentBuilder builder = new
DocumentBuilder(doc); // Insert the table from HTML. Note that AutoFitSettings does not apply to tables // inserted from HTML. builder.InsertHtml( "<table>" +
"<tr>" +
"<td>Row 1, Cell 1</td>" +
"<td>Row 1, Cell 2</td>" +
"</tr>" +
"<tr>" +
"<td>Row 2, Cell 2</td>" +
"<td>Row 2, Cell 2</td>" +
"</tr>" +
"</table>" ); doc.Save(MyDir + "DocumentBuilder.InsertTableFromHtml Out.doc" ); |
Visual Basic
12345678 |
Dim doc
As New Document()
Dim builder
As New DocumentBuilder(doc)
' Insert the table from HTML. Note that AutoFitSettings does not apply to tables ' inserted from HTML. builder.InsertHtml( "<table>" &
"<tr>" & "<td>Row 1, Cell 1</td>"
& "<td>Row 1, Cell 2</td>"
& "</tr>" &
"<tr>" & "<td>Row 2, Cell 2</td>" &
"<td>Row 2, Cell 2</td>" &
"</tr>" & "</table>" )
doc.Save(MyDir &
"DocumentBuilder.InsertTableFromHtml Out.doc" ) |