Sign in to follow this  
Followers 0
Ram

Excel to Array

6 posts in this topic

I have an excel file with four columns.. A, B, C, D and I have 10 rows in Each column..like from A1 to A10....goes on like till D1 to D10..

Now I am trying to put them to an array and then call this values to an textbox.

Is this possible through AUTO IT.

If so how do I go about doing this? are there any example? I have checked EXCELCOM but I don't see any examples...on how to use them?

Share this post


Link to post
Share on other sites



Here's some code to get you started. This will pull the data into 4 arrays, with each array representing 10 cells of a column:

#include <ExcelCOM_UDF.au3>

$oExcel = _ExcelBookOpen("C:\ExcelFile.xls") ; Open the workbook

$aColumnA = _ExcelReadArray($oExcel, 1, 1, 10, 1) ; Column A to array $aColumnA
$aColumnB = _ExcelReadArray($oExcel, 1, 2, 10, 1) ; Column B to array $aColumnB
$aColumnC = _ExcelReadArray($oExcel, 1, 3, 10, 1) ; Column C to array $aColumnC
$aColumnD = _ExcelReadArray($oExcel, 1, 4, 10, 1) ; Column D to array $aColumnD

Exit

You'll need the ExcelCOM_UDF.au3 file, which you can find by following the link in my signature. If you need more info on how to use _ExcelReadArray(), please look at the comment header for it in said file.

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

Cool.. Thanks this is really works fine but I would like to know if this can read the columns and row without opening the excel file?

Is this possible, if so how?

Awaiting your response!

Share this post


Link to post
Share on other sites

Great idea!

i think it's better to put the content of the xls in one sql file through sqlite functions and then make the output of that file. but i don't know how to do. anyone can post some code?

Share this post


Link to post
Share on other sites

Cool.. Thanks this is really works fine but I would like to know if this can read the columns and row without opening the excel file?

Is this possible, if so how?

Awaiting your response!

It will access they file, but no other file can access it while this is happening. The only way around this is to copy the file, then access the copy while you do something else with the original. (I could be wrong on this, but this has been my experience working with excel and AutoIt.)

Share this post


Link to post
Share on other sites

Cool.. Thanks this is really works fine but I would like to know if this can read the columns and row without opening the excel file?

Is this possible, if so how?

Awaiting your response!

ADODB does what you want but only when the DataWorksheet is closed.

Check the forums there are many discussions and examples.

See http://www.microsoft.com/technet/scriptcen...5/tips0607.mspx

For other ways to access excel see http://www.autoitscript.com/forum/index.ph...st&p=279861

Hope this helps.

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