Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Created April 28, 2015 19:30
Show Gist options
  • Save tmplinshi/ebf58f01bcddd36514e5 to your computer and use it in GitHub Desktop.
Save tmplinshi/ebf58f01bcddd36514e5 to your computer and use it in GitHub Desktop.
xls2arr(xlsFile, ByRef retArr) {
ComObjError(0)
Loop, % xlsFile
xlsFile := A_LoopFileLongPath
If !xl := ComObjGet(xlsFile) {
xl := ComObjCreate("Excel.Application")
xl.Workbooks.Open(xlsFile)
needClose := True
}
retArr := []
Loop, % xl.ActiveSheet.UsedRange.Rows.Count
{
row := A_Index
Loop, % xl.ActiveSheet.UsedRange.Columns.Count
retArr[row, A_Index] := xl.ActiveSheet.Cells(row, A_Index).text
}
needClose ? xl.Close : ""
Return resultArr.MaxIndex()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment