Jump to content

Export ListView in Excel


JeromeB
 Share

Recommended Posts

The Array UDF has function _ArrayDisplay which displays an array in a lsitview and lets you copy the content to the clipboard.

The Listview is copied to an array and then written to the clipboard. The example below is taken directly from arry.au3 and copies all selected listview entries to an array.

Local $aiCurItems[1] = [0]
For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
 If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
    $aiCurItems[0] += 1
    ReDim $aiCurItems[$aiCurItems[0] + 1]
    $aiCurItems[$aiCurItems[0]] = $i
 EndIf
Next

You could then use function _ExcelWriteArray to write the array to Excel.

Edited by water

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

Hey

Thx for your answer, but i dont understand how to do for put my entire listview into an array.

I have actually

$List1 = GUICtrlCreateListView("", 9, 8, 615, 374)
_GUICtrlListView_AddColumn($List1, "IP", 100)
_GUICtrlListView_AddColumn($List1, "Computer Name", 100)
_GUICtrlListView_AddColumn($List1, "User Actually Connected", 200)

And adding items with

GUICtrlCreateListViewItem($IpList & "|" & $sResult & "|" & $user, $List1)

Can you give me an exemple to show me how to procede.

Jérôme

Edited by Jerome60
Link to comment
Share on other sites

Can you give me an exemple to show me how to procede.

Sure. Something like this:

#include <Guilistview.au3>
#include <excel.au3>
GUICreate("listview items", 220, 250, 100, 200)
$listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
GUISetState()
Sleep(2000)
$oExcel = _ExcelBookNew()
$iItems = _GUICtrlListView_GetItemCount($listview)
For $iItem = 0 To $iItems-1
    $Zf = _GUICtrlListView_GetItemTextString($listview, $iItem)
    $Zf = StringSplit($Zf, "|", 1)
    _ExcelWriteArray($oExcel, $iItem + 1, 1, $Zf, 0, 1)
Next

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...