如何通过c#获取MS word doc的列表格式 [英] How to get list formats of MS word doc by c#

查看:127
本文介绍了如何通过c#获取MS word doc的列表格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有



i有一个word文档,其中我有2种不同类型的列表。

首先是:

1.美国

2.英国

3.阿联酋



和第二个就像:

i。美国

ii。英国

iii。阿联酋



所以通过c#我怎么能得到这些列表的格式。到目前为止我已尝试过:

hi all

i have a word document in which i have 2 different type of list.
first is like:
1. USA
2. UK
3. UAE

and second is like :
i. USA
ii. UK
iii. UAE

so by c# how can i get formats of these lists. i have tried so far:

object oMissing = System.Reflection.Missing.Value;
            Word.ApplicationClass oWord = new Word.ApplicationClass();
            oWord.Visible = true;
            Word.Documents oDocs = oWord.Documents;           
            object oFile = txtFileName.Text;
            // If the Microsoft Word 14.0 Object Library is referenced           
            Word._Document oDoc = oDocs.Open(ref oFile, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing);
           Word.Range rng = oDoc.Content;          
            //RunMacro(oWord, new Object[] { "Transform_HTML" });           


            MessageBox.Show(oDoc.Lists[0].StyleName.ToString());





但它没有显示任何内容。我需要这样的结果:



类型= 1



类型= i



请帮助



But it shows nothing. i need a result like this:

Type=1
or
Type=i

please help

推荐答案

阅读本文并尝试根据您的要求对此进行编码



http://www.mindstick.com/Articles/5cd1b721-9b94-4ea0-bd6e-2bb157401069/?Read%20Microsoft%20Word%20Document%20File%20by%20using%20C [ ^ ]
Read this and try to code this as per your requirement

http://www.mindstick.com/Articles/5cd1b721-9b94-4ea0-bd6e-2bb157401069/?Read%20Microsoft%20Word%20Document%20File%20by%20using%20C[^]


使用 .NET Word API在Word中设置号码列表的代码

Code to set number list in Word with .NET Word API.
//Load Document
Document doc = new Document();
doc.LoadFromFile(@"..\..\..\Sample.docx");

//Set Bullet Style
Section s = doc.Sections[0];

for (int i = 1; i< s.Paragraphs.Count; i++)
{
    Paragraph p = s.Paragraphs[i];
    p.ListFormat.ApplyNumberedStyle();
    p.ListFormat.CurrentListLevel.NumberPosition = -12;
}


这篇关于如何通过c#获取MS word doc的列表格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆