从 Word 文档中获取 Space 的字符数
Get Number of Characters with Space from Word Document
我正在使用 Microsoft.Office.Interop.Word 来计算 space 的字符数,但是当我使用内置函数时,即计数它给我更多的计数,然后从 word 文档手动查看。
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
doc = word.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);
doc.Activate();
double count = doc.Content.Characters.Count;
所以,有没有直接给字符space的方法?
试试这个
Microsoft.Office.Interop.Word.Range rng = doc.Content;
rng.Select();
int nb = rng.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticCharactersWithSpaces);
我正在使用 Microsoft.Office.Interop.Word 来计算 space 的字符数,但是当我使用内置函数时,即计数它给我更多的计数,然后从 word 文档手动查看。
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
doc = word.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);
doc.Activate();
double count = doc.Content.Characters.Count;
所以,有没有直接给字符space的方法?
试试这个
Microsoft.Office.Interop.Word.Range rng = doc.Content;
rng.Select();
int nb = rng.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticCharactersWithSpaces);