您好,
我想咨询是否可以实现如下两个功能, 非常感谢.
1.我需要将所有段落文本取消如下图中的"自动编号"功能, 相当于手动点一下取消自动编号,编号文本会保留。
2.我需要将所有段落文本取消如下图中的"自动对齐网格"功能
相关的文件在附件
Spire.Doc.Document doc = new Spire.Doc.Document();
doc.LoadFromFile(@"Test.docx");
Spire.Doc.Section section = doc.Sections[0];
foreach (Paragraph para in section.Paragraphs)
{
//设置文档网络对齐
para.Format.SnapToGrid = false;
string format = para.StyleName;
String listtext = para.ListText;
//移除自动编号
para.ListFormat.RemoveList();
//获取文本样式
TextRange origrange=(TextRange)para.ChildObjects[0];
CharacterFormat character=origrange.CharacterFormat;
string fontname=character.FontName;
float fontsize=character.FontSize;
// 从后往前处理,避免索引变化问题
if (para.ListFormat != null)
{
//添加编号文本
TextRange textRange = new TextRange(doc);
textRange.Text = listtext;
//设置文本样式
textRange.CharacterFormat.FontName = fontname;
textRange.CharacterFormat.FontSize=fontsize;
para.ChildObjects.Insert(0, textRange);
para.ApplyStyle(format);
}
}
string output = @"SetSnapToGrid.docx";
doc.SaveToFile(output, Spire.Doc.FileFormat.Docx2013);