Notifications
Clear all

Selecionar quais colunas do listview quero exportar.

5 Posts
2 Usuários
0 Reactions
1,035 Visualizações
wfranca
(@wfranca)
Posts: 297
Reputable Member
Topic starter
 

Pessoal, boa tarde.

no meu projeto existe um listview que carrega valores de uma determinada planilha.

nele tbm possuo um código onde consigo exportar dados do meu listview.

Existem uma maneira de eu selecionar quais colunas do meu listview quero que exportem?

Podem me ajudar com algum link ou exemplo...? procurei mas não achei nada semelhante.

Welington Gonçalves

 
Postado : 28/02/2015 11:15 am
cleiton jm
(@cleiton-jm)
Posts: 115
Estimable Member
 

Na hora de carregar seu listview você coloca:
ListView1.CheckBoxes = true

Para exportar você faz assim
Private Sub botao_Exportar_Click()
Dim resp As Integer
resp = MsgBox("Tem certeza que deseja exportar os registros?", vbYesNo, "Confirmação")
If resp = vbYes Then

On Error Resume Next
Dim iRow As Integer
Dim i, w, lastRow As Integer

Dim rStartCell As Range
'Plan2.Range("A2:i65536").Value = ""
Set rStartCell = Plan2.Range("A65536").End(xlUp).Offset(1, 0)
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Checked = True Then
' MsgBox ListView1.ListItems(i).Text
iRow = iRow + 1
rStartCell.Cells(iRow, 1).Value = ListView1.ListItems(i).Text
rStartCell.Cells(iRow, 2).Value = ListView1.ListItems(i).ListSubItems(1).Text
rStartCell.Cells(iRow, 3).Value = ListView1.ListItems(i).ListSubItems(2).Text
rStartCell.Cells(iRow, 4).Value = CDbl(ListView1.ListItems(i).ListSubItems(3).Text)

End If

Next

ListView1.ListItems.Clear

End If
End Sub

 
Postado : 28/02/2015 5:55 pm
wfranca
(@wfranca)
Posts: 297
Reputable Member
Topic starter
 

Legal Cleiton, funcionou para exportar as linhas selecionadas...
mas será que existe uma forma de eu escolher quais colunas do meu listview quero exportar selecionando um Checkbox?

exemplo

Checkbox1 x --- coluna A
Checkbox2 --- Coluna B
Checkbox3 x --- Coluna C

Welington Gonçalves

 
Postado : 03/03/2015 9:59 am
cleiton jm
(@cleiton-jm)
Posts: 115
Estimable Member
 

Fiz um exemplo bem simples, só você da uma estudada nele..

att

 
Postado : 03/03/2015 7:23 pm
wfranca
(@wfranca)
Posts: 297
Reputable Member
Topic starter
 

Show Cleiton..
Obrigado.

Welington Gonçalves

 
Postado : 05/03/2015 1:36 pm