Excel AIP in ASP.Net Web Page. Highlight the Excel cell if Search content is found.

Dec 10 2009 8:35 AM

Hi Teams;

Excel AIP in ASP.Net Web Page. Highlight the Excel cell if Search content is found.

 

Thanks in Advance.

Your Help is Highly Appreciate.

 

 

I Have a task, to place excel API as the part of my asp.net web page .when the user upload a excel file that should to display in the API. Beside the API a text box is there user enter a search text & Click Search button, if the search text is present in Excel API (Excel file) then the corresponding cell of excel (sheets) should highlight with Yellow back color.

 

I am achieving the same goal in Word API. What I am doing???

########################################################

1. I am using the name space Microsoft.Office.Interop.Word;

2. In page load I am display the word file in Iframe/WinWordControl.dll(3rd party tool)

3.In search button click I am open the word document & search the word phase in word document if found I am  pain it.

4. Close the word document and kill the word processor.

 

Code snap:-

******************************

 

Word.Document doc = wordApp.Documents.Open(ref file,

                ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,

                ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,

                ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);

                string m_Content = wordApp.ActiveDocument.Content.Text;

              

                foreach (Microsoft.Office.Interop.Word.Range range in doc.Words)

                {

                    if (range.Text.Trim() == txtSearchWord.Text.Trim())

                    {

                        range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkYellow;

                        range.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdWhite;

                        //wordwin.InnerText = m_Content;

                    }

             

                    else

                    {

                        lblDocContent.Text = "The Search Text:- "+ txtSearchWord.Text + " Not Found. !";

                    }

                    wordwin.Attributes["src"] = "document/GTCS.doc";

                  

                }

                wordApp.ActiveDocument.Close(ref nullobj, ref nullobj, ref nullobj);

                Killwordproc();

 

 

 

 

##  #########  ######  #####

 

 

In Case of Excel API, I am able to display the excel API in Web Page/open the document/search the text.

 

But my problem is search can perform only single column of a sheet not the all columns of sheet.

Second thing is painting the cell

 

Thanks'

Prasanta Kumar Pradhan.