This project has moved and is read-only. For the latest updates, please go here.

can i access the number of words and other statistics in doc file

Jan 12, 2011 at 3:43 PM
Edited Jan 12, 2011 at 3:44 PM

Microsoft Office Word shows this kind of information in the status bar.

is there any  way to access this kind of information specially number of words with docx library??

I could not find any at my first try.

Jan 13, 2011 at 10:41 AM

at the moment DocX does not support document statistics.
That said, word and character counts could be easily accomplished.

Below is a very simple example. I am sure that given some thought you could make this much better.
You might want to omit certain characters such as tabs?

int char_count = document.Text.length;

MatchCollection collection = Regex.Matches( document.Text, @"[\S]+");
int word_count = collection.Count;

Kind regards,