I have table html and I insert it into word document by DocumentBuilder.insertHtml() method.
In this table has few columns header display rotate. As I know Aspose has support text direction in table html by the way : Imported from "writing- mode " style attribute
But when I use : style="writing-mode: vertical-lr" attribute to header which I want rotate, this header not rotate as my expect output
Thanks for your inquiry. You issue pertains to Aspose.Words, so I am moving your query to related forum. There one of my colleague from Aspose.Words will guide you appropriately.
This attach file is my screenshot to display my issue.
As you see I want 3 final header columns display vertical so I’ve used style='writing-mode: vertical-lr' attribute. But They still display horizontal.
Hi Hanh,
Sorry for the delay. If you open this HTML in browser or MS Word, you will see the same output. You can use the following code to change the orientation of last three cells of the header row.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.PageSetup.Orientation = Orientation.Landscape;
builder.InsertHtml(System.IO.File.ReadAllText("Input.html"), true);
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
Row headerRow = table.FirstRow;
headerRow.RowFormat.Height = 100;
for (int i = headerRow.Cells.Count - 1; i > headerRow.Cells.Count - 4; i--)
{
headerRow.Cells[i].CellFormat.Orientation = TextOrientation.VerticalFarEast;
}
// foreach (Cell cell in table.FirstRow.Cells)
// {
// cell.CellFormat.Orientation = TextOrientation.VerticalFarEast;
// }
}
doc.Save("Out.docx");
Hi Muhammad,
This topic is very useful to me.
But your code above direct the text from Top to Bottom, now I want to direct the text from Bottom to Top but it still does not work.
Please help,
Thanks!
Hi Huy,
You can set TextOrientation.Upward in the above mentioned code e.g.
headerRow.Cells[i].CellFormat.Orientation = TextOrientation.Upward;
Best Regards,
I am not sure if the thread is dead. I was wondering if it is possible to find the styling from the html.
Generally, when I try to convert html <th style='Width:5%'><div class='rotate-90' style='writing-mode: vertical-lr'>Impact</div></th> to cell. I get cell.toString(SaveFormat.HTML) = <th style='Width:5%'>Impact</th>
@leangseugq You should note that Aspose.Words is designed to work with MS Word documents. And MS Word documents and HTML documents object models are quite different. This makes it not always possible to provide 100% fidelity after conversion one format to another. In most cases Aspose.Words mimics MS Word behavior when work with HTML documents.
So I am afraid there is no way to get original HTML formatting after loading HTML into Aspose.Words DOM.