我想在使用OpenXML的表格的表格單元格中應用文本對齊。使用OpenXML SDK 2.0從tableCell獲取文本的理由
我不明白爲什麼它不適用。
Table table = new Table();
TableRow tableHeader = new TableRow();
table.AppendChild<TableRow>(tableHeader);
TableCell tableCell = new TableCell();
tableHeader.AppendChild<TableCell>(tableCell);
Paragraph paragraph = new Paragraph(new Run(new Text("test")));
ParagraphProperties paragraphProperties = new ParagraphProperties();
JustificationValues? justification = GetJustificationFromString("centre");
if (justification != null)
{
paragraphProperties.AppendChild<Justification>(new Justification() { Val = justification });
}
paragraph.AppendChild<ParagraphProperties>(paragraphProperties);
tableCell.AppendChild<Paragraph>(paragraph);
public static JustificationValues? GetJustificationFromString(string alignment)
{
switch(alignment)
{
case "centre" : return JustificationValues.Center;
case "droite" : return JustificationValues.Right;
case "gauche" : return JustificationValues.Left;
default: return null;
}
}
Thx for you help!
看起來很好,您是否嘗試過從JustificationValues更改類型?到理由價值 – Kiru 2012-08-08 00:33:22
我做到了,但沒有任何變化 – Aelios 2012-08-27 07:19:40