stormlolz

Module to import a xls or csv file into a xls

6 posts in this topic

Hello,

I search a module which can import data of a xls or csv file into an other xls file

 

ex :

 

i have data in a xls file named data.xls (my data located in tab Sheet1)

 

i want to import all into an other xls file name suivi.xls (in tab Import), before delete all data of this tab

 

anyone can help me please?

 

Thank you for all

sorry for my english

 

Share this post


Link to post
Share on other sites



Have a look at the Excel UDF in Autoit Help

Share this post


Link to post
Share on other sites

Function _Excel_RangeCopyPaste is what you are looking for. Check example 2 in the help file.

1 person likes this

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

#4 ·  Posted (edited)

Hello, 

 

Thank you i will try it

Edited by stormlolz

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok thank you it's running

can we delete line with conditions before the copy ?

 

ex : delete lines where columm A:A = "0"

 

thank you

 

a part of my code

 

Case $GUI_EVENT_CLOSE
            Fin()


         Case $ButtonEXPORT

            GLOBAL $source = FileOpenDialog("", "C:\Users\", "(*.xls)", 1 + 4 )
            GUICtrlSetState($ButtonEXPORT, $GUI_DISABLE)
            GUICtrlSetState($ButtonSUIVI, $GUI_ENABLE)
            ;msgbox(0, "", $source)

         Case $ButtonSUIVI

            GLOBAL $destination = FileOpenDialog("", "C:\Users\", "(*.xlsx)", 1 + 4 )
            GUICtrlSetState($ButtonSUIVI, $GUI_DISABLE)
            GUICtrlSetState($ButtonImport, $GUI_ENABLE)
            ;msgbox(0, "", $destination)
         Case $ButtonImport

            Import()

EndSwitch
Wend
endfunc





Func Import()

; Crée un objet application et ouvre un classeur exemple
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


; Ouvre le classeur de destination
Local $oWorkbook2 = _Excel_BookOpen($oAppl, $destination, False)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel3.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oAppl)
    Exit
 EndIf



; Ouvre le classeur source
Local $oWorkbook1 = _Excel_BookOpen($oAppl, $source, True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oAppl)
    Exit
EndIf

sleep(500)

; ************************************************** ***************************

;définition de la source de la copie
Local $oRange1 = $oWorkbook1.Worksheets("export_optimus_PIC_J2013_JRecol").Range("A:G")
Local $oRange2 = $oWorkbook1.Worksheets("export_optimus_PIC_J2013_JRecol").Range("I:GG")

;définition de la destination de la copie
_Excel_RangeCopyPaste($oWorkbook2.Worksheets("Export OPTIMUS"), $oRange1, "A:G")
_Excel_RangeCopyPaste($oWorkbook2.Worksheets("Export OPTIMUS"), $oRange2, "I:GG")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "Error copying cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "L'import est terminé avec succès.")

sleep(500)
Fin()
EndFunc

 

Edited by stormlolz

Share this post


Link to post
Share on other sites

How to filter and delete rows can be found here:

 


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

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