我想在使用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