COLOCAR BORDA EM PLANILHA EXCEL

KURTGU 07/10/2015 09:53:05
#452257
Pessoal estou importando um listview para um arquivo excel ate ai tudo bem funciona direito exporta certo, somente gostaria de exportar as linhas com a grade é possivel?

[txt-color=#e80000]Funcao que ultilizo para exportar...[/txt-color]

Public Sub saveExcelFile1(ByVal FileName As String)

Try
Dim xls As New Excel.Application
Dim sheet As Excel.Worksheet
Dim i As Integer
xls.Workbooks.Add()
sheet = xls.ActiveWorkbook.ActiveSheet
Dim row As Integer = 1
Dim col As Integer = 1
For i = 0 To ListView.Columns.Count - 1
sheet.Cells(1, i + 1) = ListView.Columns(i).Text
Next
For i = 0 To ListView.Items.Count - 1
For j = 0 To ListView.Items(i).SubItems.Count - 1
sheet.Cells(i + 2, j + 1) = ListView.Items(i).SubItems(j).Text
Next
Next



sheet.Cells(22, 4) = [Ô]RELATÓRIO CEINFO HUB EQUIPE MINIMA[Ô]

row += 1
col = 1

[ô] for the header
sheet.Rows(1).Font.Name = [Ô]Microsoft Sans Serif[Ô]
sheet.Rows(1).Font.size = 9
sheet.Rows(1).Font.Bold = True
sheet.Rows(1).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter

[ô] for all the sheet without header
sheet.Range([Ô]a2[Ô], [Ô]z1000[Ô]).Font.Name = [Ô]Arial[Ô]
sheet.Range([Ô]a2[Ô], [Ô]z1000[Ô]).Font.Size = 9
sheet.Range([Ô]a2[Ô], [Ô]z1000[Ô]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter

sheet.Range([Ô]A1:X1[Ô]).EntireColumn.AutoFit()
sheet.Range([Ô]A1:X1[Ô]).EntireRow.AutoFit()

xls.ActiveWorkbook.SaveAs(FileName)
xls.Workbooks.Close()
xls.Quit()
MsgBox([Ô]DADOS EXPORTADOS COM SUCESSO...[Ô])
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

TUNUSAT 08/10/2015 09:28:48
#452291
KURTGU,

Você pode pegar a planilha inteira e colocar grade em tudo...
... bom seria +/- isso:[ô]Capturando a ultima linha preenchida (com base na coluna A)
intUltRow = shtOrigem.Range([Ô]A1048576[Ô]).End(xlUp).Row

====================================================

====================================================
Depois manda preencher tudo.

Ou montar linha a linha
                    vPlan3.Range(vPlan3.Cells(i, 1), vPlan3.Cells(i, 5)).Borders.LineStyle = xlLine


=========================================
EXCEL, VBA, 2013, OCULTAR, MOSTRAR, GUIAS, GRADES, FAIXA DE OPÇÕES, TÍTULOS, BARRA DE FÓRMULAS
https://www.youtube.com/watch?v=ZqF4_Ed2s7c
=========================================
cel vba botao ativacao oculta ou mostra linhas de grades
http://www.microsoftexcel.com.br/index.php/excel-dicas-microsoft-excel-vba/52-excel-vba-botao-de-ativacao/75-vba-botao-ativacao-oculta-ou-mostra-linhas-de-grades.html

Sub tg_mostra_retira_linhas_grade()
ActiveWindow.DisplayGridlines = Not ActiveWindow.DisplayGridlines
End Sub

=========================================
0159-Adicionando bordas a um intervalo através de Macro
https://usuariosdoexcel.wordpress.com/2013/05/15/adicionando-bordas-a-um-intervalo-atraves-de-macro/

Sub AplicandoBordas_V01()
[ô]
[ô] AplicandoBordas_V01 Macro
[ô]
[ô]
Range([Ô]A1:D10[Ô]).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End Sub


... Os elementos (itens) da coleção Borders e os seus respectivos valores numéricos são:
5 - xlDiagonalDown
6 - xlDiagonalUp
7 - xlEdgeLeft
8 - xlEdgeTop
9 - xlEdgeBottom
10 - xlEdgeRight
11 - xlInsideVertical
12 - xlInsideHorizontal
...

Assim como a coleção Borders, a propriedade LineStyle pode apresentar uma série de valores definidos pelas constantes a seguir. Ao lado de cada uma está a descrição do tipo de linha que define.

Nome - Descrição
xlContinuous - Linha contínua
xlDash - Linha tracejada
xlDashDot - Traços e pontos alternados
xlDashDotDot - Traço seguido por dois pontos
xlDot - Linha pontilhada
xlDouble - Linha dupla
xlLineStyleNone - Sem linha
xlSlantDashDot - Traços inclinados

Para uma análise detalhada sobre ColorIndex visite o post: http://wp.me/p1uYv4-gC

A espessura (Weight) pode assumir os valores a seguir:

Nome Descrição
xlHairline - Fio (a borda mais fina)
xlThin - Fina
xlMedium - Média
xlThick - Grossa
...
=========================================

[][ô]s,
Tunusat.
Tópico encerrado , respostas não são mais permitidas