Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone:
how can I search special cell in .doc file and write some word in it in asp.net.thank you!




novel
2013-1-8
Posted
Comments
yizhiduxiunie 10-Jan-13 9:03am    
how can I search special cell in .doc file if it have one more table? thank you!


novel
2013-1-10

Hello,
The special cell? Cell in Word table or just text in .doc file?
If you just want to search special text, the following code may be helpful.
C#
//load a document
Document document = new Document();
document.LoadFromFile(@"..\..\..\DocSample.doc");

//Find text
TextSelection[] textSelections = document.FindAllString("TextString", true, true);

For writing, you need to replace the found text if you want to write words in the same place. Or you can create a new paragraph to write words.
Replace:
C#
document.Replace("TextString", "ReplaceString",true,true);

Write:
C#
Section section = document.Sections[0];
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("New String");

You can visit .NET Word project to get more information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900