ExcelToArray - Read excel data to AHK array

Post your working scripts, libraries and tools
Posts: 1190
Joined: 01 Oct 2013, 14:57

ExcelToArray - Read excel data to AHK array

22 Jun 2018, 03:21

Source (GitHub)

arr := ExcelToArray(FileName, nSheet, last_row, last_column)

  • FileName - The excel file path.
  • nSheet - (Optional) Sheet number. Default is 1.
  • last_row - (Optional) Last row number.
  • last_column - (Optional) Last column number.
Example of output array:

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus

Example: Load excel data to Listview

Note: This function uses sheet.Range(cell_begin, cell_end).FormulaR1C1 (instead of .Value) to read the data, it can avoids the numbers such as 1.2 converted into 1.200000. But if the cell contains formula, the formula code itself will be read, not the actual value.

Related script: Create excel file from array or listview
Last edited by tmplinshi on 22 Jun 2018, 09:13, edited 1 time in total.
Posts: 489
Joined: 22 Jan 2017, 19:37

Re: ExcelToArray - Read excel data to AHK array

22 Jun 2018, 07:43

@tmplinshi, thank you! That works very well. Nice trick using dat* to add any number of colums.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 11 guests