Jump to content

Excel to Array


Ram
 Share

Recommended Posts

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?

Link to comment
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]
Link to comment
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.)
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...