We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Word Count & Return all words from Document

Thread ID:

Created:

Updated:

Platform:

Replies:

71042 Jan 13,2008 05:10 AM Jan 14,2008 01:47 AM Windows Forms 1
loading
Tags: DocIO
Mac
Asked On January 13, 2008 05:10 AM

Hi all,

i'm evaluating the Syncfusion.DocIO coz' we need a logic to get every word in a *.doc file as a single string object. How can this be done?

Can this work like the following example (i know this is not a working one ;-)

'---------------------------------------------
Function GetWords() As ArrayList

Dim wordsArray As New ArrayList
Dim currentWord As String

Dim document As DocIO.DLS.WordDocument = _
New DocIO.DLS.WordDocument

document.Open(fileName, FormatType.Doc)

For Each currentWord In document.GetText
wordsArray.Add(currentWord)
Next

Return wordsArray
End Function
'---------------------------------------------

Your help is much appreciated...
Regards,
Mac


Administrator [Syncfusion]
Replied On January 14, 2008 01:47 AM

Hi Mac,

Thank you for evaluating Syncfusion products.

Word count

You can display number of words in a document using WordCount property of document as follows.

[C#]

doc.BuiltinDocumentProperties.WordCount

To return all the words in a document

We don't have direct support for displaying all the words in a document. You need to enumerate the document elements starting from sections and need to check whether each paragraph item in the section contains any Text to display. Here is a code snippet.

[C#]

// Enumerate the document elements starting from sections
foreach (IWSection sec in doc.Sections)
{
foreach (IWParagraph para in sec.Paragraphs)
{
for (int i = 0; i < para.ChildEntities.Count; i++)
{
Syncfusion.DocIO.DLS.IParagraphItem pItem = para[i] as Syncfusion.DocIO.DLS.IParagraphItem;

//Check if the type of element is a text
if (pItem is IWTextRange)
{
IWTextRange cellText = pItem as IWTextRange;
String s = cellText.Text.ToString();
Console.WriteLine(s.ToString());

}

}
}

Finally , you can display all the words in a string IWTextRange.Text.

Sample reference

Please refer the sample that demonstrates the same.

http://websamples.syncfusion.com/samples/DocIO.Windows/F71041/main.htm

Please let me know if this helps you.

Regards,
Jaya





CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;