Jump to content

Recommended Posts

Firs of all, i'm sorry for my bad english, but i'm brazilian!

I've modified many functions of Excel.au3 to make it much more fast and created anothers functions

the function list is above:

Functions inside UDF:

_ExcelColumnLetter($iColumn)

_ExcelColumnNumber($sColumn)

_ExcelFormatR1C1ToA1($iRowFrom, $iColFrom, $iRowTo = "", $iColTo = "")

_ExcelFormatA1ToR1C1($sRange)

_ExcelReadSheetToArrayEX($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0, $iColShift = 0)

_ExcelPasteSpecial($oExcel, $sRange, $xPasteType = -4104, $xPasteSpecialOp = -4142)

_ExcelFormatPainter($oExcel, $sRangeFrom, $sRangeTo = 0, $xPasteType = -4104, $xPasteSpecialOp = -4142)

_ExcelWriteSheetFromArrayEx($oExcel, $aArray, $iStartRow = 1, $iStartColumn = 1, $iArrayRowStart = 0, $iArrayColStart = 0)

_ExcelWriteArrayEX($oExcel, $aArray, $iStartRow = 1, $iStartColumn = 1, $iArrayRowStart = 0, $iDirection = 0)

if someone wants to fix my specifications can be at ease!

in the attached file have a examples of functions!

Note:

functions that are written by other people and i just modified, i left specified within the UDF

I hope it is useful to you, it's much more fast than original functions!

Thanks a lot!

Examples:

#include 
#include 

;Generate an Array
Local $aArray[100][15]

For $i = 0 To 99
For $j = 0 To 14
$aArray[$i][$j] = "Line: " & $i + 1 & " - Col: " & $j + 1
Next
Next

;Create Excel Object
Local $oExcel = _ExcelBookNew()

;Write a 2d Array to Excel with default values (start in R1C1 cell and write all itens in array).
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteSheetFromArrayEx($oExcel, $aArray)
$oExcel.ActiveSheet.Columns("A:O").AutoFit

;Format 2 First's lines.
MsgBox(0,'',"Press OK to format the 2 first Excel cells.")
With $oExcel.ActiveSheet.Range("A1:O100")
.Select
.HorizontalAlignment = 3
.Borders.LineStyle = 1
EndWith
$oExcel.ActiveSheet.Range("A1:O1").Interior.Color = 0xDAC0CC
$oExcel.ActiveSheet.Range("A2:O2").Interior.Color = 0xF0B00A
$oExcel.ActiveSheet.Range("A2:O2").Font.Bold = True


;Copy this style to all anothers Cells with _ExcelFormatPainter
MsgBox(0,'',"Press OK to copy the style of the 2 first's cells to to all anothers cells.")
_ExcelFormatPainter($oExcel, "A1:O2", 0, $xlPasteFormats, $xlPasteSpecialOperationNone)
$oExcel.ActiveSheet.Range("A1").Select


;Read all data to array
MsgBox(0,'',"Press OK to read all cells to and array.")
Local $aCells = _ExcelReadSheetToArrayEX($oExcel)
_ArrayDisplay($aCells)

;read 3 columns from Excel starting from 5nd and 50 rows starting from 1st row
MsgBox(0,'',"Press OK to read 50 rows and 3 cols and to and array.")
Local $aCells = _ExcelReadSheetToArrayEX($oExcel, 1, 5, 50, 3)
_ArrayDisplay($aCells)


_ExcelBookClose($oExcel)

;Create another Excel Object
Local $oExcel = _ExcelBookNew()

;Write an Array to Excel Starting from 50 row and 12 col of array and write it starting from 2nd row and 3rd col of excel
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteSheetFromArrayEx($oExcel, $aArray, 2, 3, 50, 12)
MsgBox(0,'',"Press OK to Close.")
_ExcelBookClose($oExcel)

;Write an 1D Array
Local $oExcel = _ExcelBookNew()
Local $aArray[5] = ["LocoDarwin", "Jon", "big_daddy", "DaleHolm", "GaryFrost"]
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteArrayEX($oExcel, $aArray) ; Write the Array Horizontally
_ExcelWriteArrayEX($oExcel,$aArray, 5, 1, 0, 1) ; Write the Array Vertically, starting on the 5th Row

MsgBox(0,'',"Press OK to Exit.")
_ExcelBookClose($oExcel)

ExcelEX.rar

Edited by golfinhu
Link to comment
Share on other sites

MOST EXCELLENT!

I've already tried and tested, as you know golfinhu, this one: _ExcelReadSheetToArrayEX($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0, $iColShift = 0)

Its extremely fast, 10 x 's as fast actually, if not faster, and works GREAT! I'm not sure what corners you cut to increase the time, but man, it produces the same results, and 1000x faster!

I use it most every one of my apps I build for work. I can't think you enough. As you know, I requested you to do the same with the_ExcelWriteSheetFromArrayEx

But this is even better. So many newer faster functions to play with. I can't wait to get my hands on them! Its like its my birthday!

As soon as I get a chance to test the new ones above, I'll post back here and let you know. Thanks again!

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

I downloaded the ExcelEX.rar file to Windows 7 today and was able to unrar/unzip it using 7Zip without problems.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I downloaded the ExcelEX.rar file to Windows 7 today and was able to unrar/unzip it using 7Zip without problems.

I know, downloading compressed files off the forum still works for many of us, but as of a few months ago, not for some of us. Both my work and home machines have the problem, BrewManNH has a machine with the problem, and apparently ptrex too. if I searched around the forums I could probably find a dozen "Your zip file is bad!" comments related to the issue. Compressed files downloaded from the forum are coming down compressed a second time in the GZip format. I started a thread in the "chat" forum about it.

Edit: Using 7Zip may also be a work-around for the issue, as I only have WinZip and WinRar installed.

Edited by Spiff59
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

×
×
  • Create New...