Sign in to follow this  
Followers 0
golfinhu

ExcelEX

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



someone tested?

noticed a bug?

please report it to me!

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Hi golfinhu,

perfect !!!! :ILA2:

I can't belive the speed.

Please keep on working at the other functions.

Thanks for sharing!

Greets

Dizzy

Share this post


Link to post
Share on other sites

Rename the downloa

@golfinhu

The ExcelEx in the Zip file seems broken and can't be extracted ?

rgds

ptrex

Rename the downloaded file to ExcelEx.rar.gz. Extracting that will result in a ExcelEX.rar file that will then extract correctly.

Share this post


Link to post
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.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

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

  • Similar Content

    • VeryGut
      By VeryGut
      I'm trying to insert the following formula in cell A2 using my script:
      =if(A1=""; "YES"; "NO")
      To my understanding, the line of code should be similar to this:
      _Excel_RangeWrite($MasterFile, Default, "=if(A1=""; "YES"; "NO")", "A2")
      However, it does not work, probably due to the multiple quotation marks that confuse the script :C
      How do I avoid this problem?
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a question about Excel, i have to create several charts one below the other dynamically.
      I have thought to use:
       
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count  
      And then to use it in this way:
      $Graph_position = "=Test1!A"&$iRowCount+2&":K"&$iRowCount+24 But it doesn't work with charts.
      Does anyone have a suggestion?
       
    • LoneWolf_2106
      By LoneWolf_2106
      Hi all,
      i have an empty csv file, i have a non formatted text file.
      What do i want to do?
      I want to automate the process "get external data" in Excel, i want to import the data from the text file and basically create a csv file with a specific character encoding.
      Is it possible with AutoIT?
       
    • breakbadsp
      By breakbadsp
      I  want to create a excel file from my script if it does not exist.
      _ExcelBookOpen throws error=2 if file does not exist, after this error i want to create new file at this point.
      can i use _FileCreate()?
      _Logger($sLogPath, "{INFO}------: Opening Excel File: " & $sExcelPath& "") While 1 Local $oExcelTestResult = _ExcelBookOpen($sExcelPath) If @error = 2 Then If not _FileCreate($sResExcelPath) Then MsgBox(0, "Error", "Error In Opening REsult Excel File: Error: " & String(@error)) _Logger($sLogPath, "{ERROR}------: Result Excel File does not exist.. tried to create new but :ERROR : " & String(@error) & "") ExitLoop Else _Logger($sLogPath, "{INFO}------: Result Excel File does not exist.. **Created New**: ") EndIf Else ExitLoop EndIf WEnd  
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have to store an entire row of a Excel workbook into an array.  The row index is stored in a variable.
      How can i do it?
      Thanks in advance for your support.