Spread Text Search

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

  • Posted 8 September 2017, 2:25 pm EST

    <p>Hi,</p><p>int rowindex=-1;</p><p>int colindex=-1; </p><p>spread.Search<br>                        (<br>                            sheetNumber,<br>                            "Ram" + "*",<br>                            false,<br>                            true,<br>                            false,<br>                            true,<br>                            true,<br>                            false,<br>                            false,<br>                            true,<br>                            0,<br>                            spread.ActiveSheet.ActiveColumn.Index,<br>                            spread.ActiveSheet.RowCount - 1,<br>                            spread.ActiveSheet.ActiveColumn.Index,<br>                            ref rowindex,<br>                            ref colindex<br>                        ); </p><p>spread.ActiveSheet.ActiveColumnIndex = colindex;<br>                spread.ActiveSheet.ActiveRowIndex = rowindex; </p><p> </p><p>Note:-</p><p>1-Suppose i have two rows</p><p>Tuka Ram</p><p>Ram Nath</p><p>when we search with above method its find "Tuka Ram" but we want "Ram Nath".</p><p>We want to search only start value not in between of the sentence.</p><p> 2- We have 9000 row in our Item table.</p><p>when we search data of the active column, it takes 1-2 minutes to reach target cell.</p><p>In previous version of VB compatible spread takes only 2-5 seconds.</p><p> </p><p>Please tell me how we increase the search speed.</p><p> </p><p> </p><p>Thanks and Regards,</p><p>Ram Nath Verma</p><p>Mumbai(INDIA) <br></p><p> </p>
  • Replied 8 September 2017, 2:25 pm EST

    <p>Hello Ramnath,</p><p>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:-</p><blockquote><p>    private void button1_Click(object sender, EventArgs e)
    <br>        {
    <br>            for (int rowIndex = 0; rowIndex < fpSpread1.ActiveSheet.Rows.Count - 1; rowIndex++)
    <br>            {
    <br>                String Mystring = fpSpread1.ActiveSheet.GetText(rowIndex, 0);
    <br>                if (Mystring.Length >= 3)
    <br>                {
    <br>                    string MysubStr = Mystring.Substring(0, 3);
    <br>                    if (MysubStr == "Ram")
    <br>                    {
    <br>                        fpSpread1.ActiveSheet.Cells[rowIndex, 0].BackColor = Color.Red;
    <br>                    }
    <br>                }
    <br>            }
    <br>        } </p></blockquote><p>Hope this will help you. Thanks.<br></p>
  • Replied 8 September 2017, 2:25 pm EST

    <p>Hi,</p><p>Thanks for reply.</p><p>It is not possible to we find fixed length.</p><p>If any dynamic option then tell me.</p><p>What to say about speed of searching.</p><p>Search is inbuilt function then why it execute very slow.  </p><p> </p><p>thanks and regards,</p><p>Ram Nath Verma</p><p>MUMBAI(INDIA) <br></p><p> </p>
  • Replied 8 September 2017, 2:25 pm EST

    <p>Hello,</p><p>I rewrite the code for Search have a look at the folliwing code snippet,</p><p> private void button1_Click(object sender, EventArgs e)<br>        {<br>            <br>            fpSpread1.Search(0,<br>                            "Ram",<br>                            false,<br>                            false,<br>                            true,<br>                            true,<br>                            true,<br>                            false,<br>                            false,<br>                            true,<br>                            rowindex+1,<br>                            fpSpread1.ActiveSheet.ActiveColumn.Index,<br>                            fpSpread1.ActiveSheet.RowCount-1,<br>                            fpSpread1.ActiveSheet.ActiveColumn.Index,<br>                            ref rowindex,<br>                            ref colindex<br>                        );<br>            int tempRowIndex = rowindex;<br>            fpSpread1.Search(0,<br>                            "?Ram",<br>                            false,<br>                            false,<br>                            true,<br>                            true,<br>                            true,<br>                            false,<br>                            false,<br>                            true,<br>                            rowindex,<br>                            fpSpread1.ActiveSheet.ActiveColumn.Index,<br>                            rowindex,<br>                            fpSpread1.ActiveSheet.ActiveColumn.Index,<br>                            ref rowindex,<br>                            ref colindex<br>                        );<br>            if (rowindex == -1)<br>            {<br>                rowindex = tempRowIndex;<br>                fpSpread1.ActiveSheet.ActiveColumnIndex = colindex;<br>                fpSpread1.ActiveSheet.ActiveRowIndex = rowindex;<br>                <br>            }<br>        } </p><p>Also the search performance is good , I tested for 500 rows.<br></p><p>Thanks,</p><p> </p>
Need extra support?

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

Learn More

Forum Channels