TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
V G S Naidu A
NA
63
18.3k
How to search the text in WebBrowser Control
Dec 20 2012 7:35 AM
Hai,
we have a requirement like previewing the documents as like in windows7/vista
"
preview Pane
" and have to implement the
search
functionality in Winforms.For that,
I have loaded the Ms office docuemnts, and Excel Sheets and Power Point documents into
Webbrowser
Control in html format.Now we need to implement the search functionality in that webbrowser Control.
For that we have implemented the search functionality using the following code
public bool FindNext(string text, WebBrowser webBrowser1)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
IHTMLSelectionObject sel =doc.selection;// (IHTMLSelectionObject)doc.selection;
IHTMLTxtRange rng = sel.createRange() as IHTMLTxtRange;
rng.collapse(false); // collapse the current selection so we start from the end of the previous range
if (rng.findText(text, 1000000, 0))
{
rng.select();
return true;
}
else
FindFirst(text, webBrowser1);
return false;
}
This code is working fine for searching the string values in
word Document
for all the occurences.
But when it Comes to
Excel and PPt
documents this code doesn't work properly.it finds only the first occurrence of the string other occurrences doesn't find.
while debugging i found that,for word Documents "IHTMLDocument2" object stores the html Content in "innerHTML" and "innerText" with some values.
But for Excel it stores the text in "innerHTML" only by using the Frames, and sheets are referenced to local temporary .html files and it didn't have any "innerText" content it showing as null.
Please provide the solution to search the text in webbrowser control which loaded the html content, that is converted from Excel,PPT to html type and displaying in webbrowser control.
If you have any queries please feel to ask me.
Thank You.
Attachment:
exceldocumentsavedas.rar
Reply
Answers (
0
)
How to save time Interval before is ends?
Create board 5X5 ,red,black