VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Quickest way to export a listview to Excel

Brian Dunn  (1 Submission)   OLE/COM/DCOM/Active-X   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This is a faster way to take a listview control and display its contents in a new Excel workbook.
A common mistake in using OLE to manipulate Excel is to send data values one cell at a time. However, if you are exporting listview, it is much faster to create a two-dimensional array of the data and then send the entire array to Excel all at once. This method can be applied to grids, recordsets, or any other table-like data.
This code will also allow the user to select multiple, non-contiguous rows for export. Hidden columns are not exported, either. Also, if the ColumnHeader.Tag properties have been set to "string", "number", or "date", the Excel columns will be formatted as such.

Inputs
A reference to a ListView control.

Assumes
The listview allows multiple row selection.

Returns
True if it worked, False if not

Rate Quickest way to export a listview to Excel (8(8 Vote))
Quickest way to export a listview to Excel.bas

Quickest way to export a listview to Excel Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters