C#OpenXML-表属性-设置从左到右的缩进
我有一个word文档,第一页有一个表格。它是文档上的第一个表,并且只是第一页中的一个表。我需要将此表上的“从左缩进”设置为0。我已经在文档中添加了一些文本:C#OpenXML-表属性-设置从左到右的缩进,c#,openxml,C#,Openxml,我有一个word文档,第一页有一个表格。它是文档上的第一个表,并且只是第一页中的一个表。我需要将此表上的“从左缩进”设置为0。我已经在文档中添加了一些文本: using (WordprocessingDocument oDocument = WordprocessingDocument.Open(_ms, true)) { //Set paragraph, run, and runproperties objects. Paragraph para = oDocument.Ma
using (WordprocessingDocument oDocument = WordprocessingDocument.Open(_ms, true))
{
//Set paragraph, run, and runproperties objects.
Paragraph para = oDocument.MainDocumentPart.Document.Descendants<Paragraph>().First();
Run run = para.AppendChild(new Run());
RunProperties runPro = new RunProperties();
Run lineBreak = new Run(new Break());
//Set the text color and text value
Color color = new Color() { Val = "FFFFFF" };
Text text1 = new Text();
text1.Text = "text";
//Add the text to the body
runPro.Append(color);
run.Append(runPro);
run.Append(text1, lineBreak);
//Close the handle
oDocument.Close();
}
使用(WordprocessingDocument oDocument=WordprocessingDocument.Open(\ms,true))
{
//设置段落、运行和运行属性对象。
段落para=oDocument.MainDocumentPart.Document.subjects().First();
Run-Run=para.AppendChild(new Run());
RunProperties runPro=新的RunProperties();
Run lineBreak=新运行(new Break());
//设置文本颜色和文本值
颜色=新颜色(){Val=“FFFFFF”};
Text text1=新文本();
text1.Text=“Text”;
//将文本添加到正文中
runPro.Append(彩色);
Append(runPro);
run.Append(text1,lineBreak);
//关上把手
气味文件。关闭();
}
我读过一些关于TableIndentation类的文章,但是没有发现任何使用它的例子。有人有过这样的经验吗
谢谢。您是否尝试过使用(请注意,此页面上有多个下载)检查包含您所需内容的文档?如果没有,请这样做。它将回答您的问题。您可以像这样在table properties类中指定表格缩进
TableProperties tPr = new TableProperties();
tPr.TableIndentation = new TableIndentation() { Type = indentationType, Width = indentationWidth };
使用此选项并在
DXA(1”=1440左右)中提供宽度
在TableWidth类MSDN库下1440点的二十分之一(1英寸),因为1440点的二十分之一/20=72和72点=1英寸
props.TableIndentation = new TableIndentation() { Type = TableWidthUnitValues.Dxa, Width=-997 };