How to use GoExcel.FindRowStart

<?xml encoding=”UTF-8″>By Xiaodong Liang

Question
In an Excel file, the cells are defined as below. I wanted to get the row which aaa =111. I thought the first is to call
GoExcel.FindRowStart = 3, because GoExcel.FindRowStart is 2 in default. But, FindRow failed after FindRowStart = 3. It says:
Could not match the column title: “aaa”

clip_image002

GoExcel.Open(Book1.xlsx, Sheet1)
GoExcel.FindRowStart = 3
i = GoExcel.FindRow(Book1.xlsx, Sheet1, aaa, =, 111)
MessageBox.Show(i.Tostring(), Title)

Solution
There is another property: TitleRow. You also have to set that.  (Or you can set TitleRow only, and FindRowStart will be set automatically to TitleRow+ 1). Here’s a modified version of the rule:

<span><font color="#800080"><strong>GoExcel</strong></font></span><span><font color="#000000">.</font></span><strong><span><font color="#800080">Open</font></span><span><font color="#000000">(</font></span></strong><font color="#008080"><span>"</span><span>Book1.xlsx</span><span>"</span></font><span><font color="#000000">, </font></span><font color="#008080"><span>"</span><span>Sheet1</span><span>"</span></font><span><strong><font color="#000000">)</font></strong></span><span>
</span><font><span><font color="#800080"><strong>GoExcel</strong></font></span><span><font color="#000000">.</font></span><span><font color="#800080"><strong>TitleRow</strong></font></span><font color="#000000"><span> </span><span><strong>=</strong></span><span> </span><span><strong>2</strong></span></font></font><span>
</span><span><font color="#800080"><strong>GoExcel</strong></font></span><span><font color="#000000">.</font></span><span><font color="#800080"><strong>FindRowStart</strong></font></span><font color="#000000"><span> </span><span><strong>=</strong></span><span> </span><span><strong>3<br></strong></span></font><font color="#808080"><em><span>'</span><span> or set TitleRow only if you are sure the start row is TitleRow +1 </span></em></font><span>
</span><span><font color="#800000">i</font></span><font color="#000000"><span> </span><span><strong>=</strong></span><span> </span></font><span><font color="#800080"><strong>GoExcel</strong></font></span><span><font color="#000000">.</font></span><strong><span><font color="#800080">FindRow</font></span><span><font color="#000000">(</font></span></strong><font color="#008080"><span>"</span><span>Book1.xlsx</span><span>"</span></font><span><font color="#000000">, </font></span><font color="#008080"><span>"</span><span>Sheet1</span><span>"</span></font><span><font color="#000000">, </font></span><font color="#008080"><span>"</span><span>aaa</span><span>"</span></font><span><font color="#000000">, </font></span><font color="#008080"><span>"</span><span>=</span><span>"</span></font><font color="#000000"><span>, </span><strong><span>111</span><span>)</span></strong></font><span>
</span><span><font color="#800080"><strong>MessageBox</strong></font></span><span><font color="#000000">.</font></span><strong><span><font color="#800080">Show</font></span><span><font color="#000000">(</font></span></strong><span><font color="#800000">i</font></span><span><font color="#000000">.</font></span><span><font color="#800000">Tostring</font></span><font color="#000000"><span><strong>()</strong></span><span>, </span></font><font color="#008080"><span>"</span><span>Title</span><span>"</span></font><span><strong><font color="#000000">)</font></strong></span><span>
</span>

Comments

One response to “How to use GoExcel.FindRowStart”

  1. Zavier Mattson Avatar
    Zavier Mattson

    Over a decade late to the party but I was just working with GoExcel and discovered something that needs to be mentioned in case someone comes across this like I did.
    FindRowStart IS NOT necessarily automatically set to TitleRow + 1, you need to explicitly set it each time if your script dynamically sets the TitleRow more than once.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading