Spread Text Search

Posted by: ramnath-fp on 8 September 2017, 2:25 pm EST

  • Posted 8 September 2017, 2:25 pm EST

    Hi,

    int rowindex=-1;

    int colindex=-1;

    spread.Search
                            (
                                sheetNumber,
                                "Ram" + "*",
                                false,
                                true,
                                false,
                                true,
                                true,
                                false,
                                false,
                                true,
                                0,
                                spread.ActiveSheet.ActiveColumn.Index,
                                spread.ActiveSheet.RowCount - 1,
                                spread.ActiveSheet.ActiveColumn.Index,
                                ref rowindex,
                                ref colindex
                            );

    spread.ActiveSheet.ActiveColumnIndex = colindex;
                    spread.ActiveSheet.ActiveRowIndex = rowindex;

     

    Note:-

    1-Suppose i have two rows

    Tuka Ram

    Ram Nath

    when we search with above method its find "Tuka Ram" but we want "Ram Nath".

    We want to search only start value not in between of the sentence.

     2- We have 9000 row in our Item table.

    when we search data of the active column, it takes 1-2 minutes to reach target cell.

    In previous version of VB compatible spread takes only 2-5 seconds.

     

    Please tell me how we increase the search speed.

     

     

    Thanks and Regards,

    Ram Nath Verma

    Mumbai(INDIA)

     

  • Replied 8 September 2017, 2:25 pm EST

    Hello Ramnath,

    You can use the code given below in order to find Text in Cells starting with Ram rather than in between sentences. Please have a look at the code:-

        private void button1_Click(object sender, EventArgs e)

            {

                for (int rowIndex = 0; rowIndex < fpSpread1.ActiveSheet.Rows.Count - 1; rowIndex++)

                {

                    String Mystring = fpSpread1.ActiveSheet.GetText(rowIndex, 0);

                    if (Mystring.Length >= 3)

                    {

                        string MysubStr = Mystring.Substring(0, 3);

                        if (MysubStr == "Ram")

                        {

                            fpSpread1.ActiveSheet.Cells[rowIndex, 0].BackColor = Color.Red;

                        }

                    }

                }

            }

    Hope this will help you. Thanks.

  • Replied 8 September 2017, 2:25 pm EST

    Hi,

    Thanks for reply.

    It is not possible to we find fixed length.

    If any dynamic option then tell me.

    What to say about speed of searching.

    Search is inbuilt function then why it execute very slow. 

     

    thanks and regards,

    Ram Nath Verma

    MUMBAI(INDIA)

     

  • Replied 8 September 2017, 2:25 pm EST

    Hello,

    I rewrite the code for Search have a look at the folliwing code snippet,

     private void button1_Click(object sender, EventArgs e)
            {
               
                fpSpread1.Search(0,
                                "Ram",
                                false,
                                false,
                                true,
                                true,
                                true,
                                false,
                                false,
                                true,
                                rowindex+1,
                                fpSpread1.ActiveSheet.ActiveColumn.Index,
                                fpSpread1.ActiveSheet.RowCount-1,
                                fpSpread1.ActiveSheet.ActiveColumn.Index,
                                ref rowindex,
                                ref colindex
                            );
                int tempRowIndex = rowindex;
                fpSpread1.Search(0,
                                "?Ram",
                                false,
                                false,
                                true,
                                true,
                                true,
                                false,
                                false,
                                true,
                                rowindex,
                                fpSpread1.ActiveSheet.ActiveColumn.Index,
                                rowindex,
                                fpSpread1.ActiveSheet.ActiveColumn.Index,
                                ref rowindex,
                                ref colindex
                            );
                if (rowindex == -1)
                {
                    rowindex = tempRowIndex;
                    fpSpread1.ActiveSheet.ActiveColumnIndex = colindex;
                    fpSpread1.ActiveSheet.ActiveRowIndex = rowindex;
                   
                }
            }

    Also the search performance is good , I tested for 500 rows.

    Thanks,

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels