从Word文件中获取样式列表

时间:2016-11-18 08:53:50

标签: c# asp.net ms-word

有没有办法获取word文件中包含的所有样式名称的列表?我正在使用Spire.Doc,我知道如何获得所有使用的样式,但我需要所有可用的样式名称。

List should include these styles

1 个答案:

答案 0 :(得分:0)

检查:

object missing = System.Reflection.Missing.Value;
object fileName = "C:\\test.docx";
Microsoft.Office.Interop.Word.Application applicationWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document documentWord = new  Microsoft.Office.Interop.Word.Document();
documentWord = applicationWord.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref  missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
foreach (Microsoft.Office.Interop.Word.Style currentStyle in documentWord.Styles)
{
     string name = currentStyle.NameLocal;
}