Sign in to follow this  
Followers 0
inwmsn

How to count total cell in _ExcelReadArray

3 posts in this topic

Hi There,

I couldn't figure out how to define the exactly array range in _ExcelReadArray as following

_ExcelReadArray($oExcel, $iStartRow, $iStartColumn, $iNumCells, $iDirection = 0, $iIndexBase = 0)

When this function running, it read the whole data range depend on $iNumberCells defined. If I set as 255, It will read up to 255 in range event there is only 3 data in range. So, it will read nothing afther 3rd range when I put into loop. For example

In the email.xls;

A1 - xxxx@hotmail.com

A2 - yyyy@gmail.com

A3 - zzzz@yahoo.com

-------------------------------------------------------------------------

$oExcel = "d:\scripts\email.xls"

_ExcelBookOpen ($oExcel,1)

Dim $import = _ExcelReadArray($oExcel, 1, 1, 255, 1, 1)

_ExcelBookClose($oExcel)

For $i = 1 To Ubound ($import) -1

MsgBox (0,0,$import[$i])

Next

-------------------------------------------------------------------------

Result

The script will keep looping popup the message until A255 range.

Question

How can I give the script stop looping after A3 or stop after empty data range?

Thanks

Share this post


Link to post
Share on other sites



How can I give the script stop looping after A3 or stop after empty data range?

test the result ; i.e. if StringLen(StringStripWs($result,3)) = 0 then .....


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

You are a man! Thanks so much.

Hi There,

I couldn't figure out how to define the exactly array range in _ExcelReadArray as following

_ExcelReadArray($oExcel, $iStartRow, $iStartColumn, $iNumCells, $iDirection = 0, $iIndexBase = 0)

When this function running, it read the whole data range depend on $iNumberCells defined. If I set as 255, It will read up to 255 in range event there is only 3 data in range. So, it will read nothing afther 3rd range when I put into loop. For example

In the email.xls;

A1 - xxxx@hotmail.com

A2 - yyyy@gmail.com

A3 - zzzz@yahoo.com

-------------------------------------------------------------------------

$oExcel = "d:\scripts\email.xls"

_ExcelBookOpen ($oExcel,1)

Dim $import = _ExcelReadArray($oExcel, 1, 1, 255, 1, 1)

_ExcelBookClose($oExcel)

For $i = 1 To Ubound ($import) -1

MsgBox (0,0,$import[$i])

Next

-------------------------------------------------------------------------

Result

The script will keep looping popup the message until A255 range.

Question

How can I give the script stop looping after A3 or stop after empty data range?

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0