Jump to content
Fivewin Brasil

TOleauto - Largura da coluna no excel


Geraldo (gbsilva)

Recommended Posts

Pessoal acabei descobrindo uma dica antiga e lá tinha o que eu precisava, mas aproveitando será que alguém teria uma listagem completa dos métodos e atributos da TOleauto.

Tem mais uma coisa que tenho de fazer no relatório do excel que é quebrar automaticamente para que o texto seja apresentado na coluna de modo a ser lido, hoje o usuário tem que configurar, mas sempre o ideal é deixar tudo pronto via programação.

Abaixo o que encontrei nos meus arquivos pode ser útil para alguém:

FUNCTION MAIN()
LOCAL oExcel, oSheet
oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet := oExcel:Get( "ActiveSheet" )
oSheet:Name := "Aba 1"
oSheet:Cells( 1, 1 ):Value := "Codigo"
oSheet:Cells( 1, 2 ):Value := "Nome"
oExcel:Sheets:Add()
oSheet := oExcel:Get( "ActiveSheet" )
oSheet:Name := "Aba 2"
oSheet:Cells( 1, 1 ):Value := "Data"
oSheet:Cells( 1, 2 ):Value := "Valor"
oSheet:Cells( 1, 1 ):Select()
oExcel:Visible := .T.
Return Nil

Preencher as células: Cells(linha,coluna):Value
oSheet:Cells( 2, 1 ):Value := "NÃO"
oSheet:Cells( 2, 2 ):Value := " N O M E D O P A I"
oSheet:Cells( 2, 3 ):Value := " N O M E D O A L U N O"
oSheet:Cells( 2, 4 ):Value := "Ano"
oSheet:Cells( 2, 5 ):Value := "Mensalidade"
oSheet:Cells( 2, 6 ):Value := "Apostila"
oSheet:Cells( 2, 7 ):Value := "Xerox"
oSheet:Cells( 2, 8 ):Value := "Uniforme"
oSheet:Cells( 2, 9 ):Value := "R.O."
oSheet:Cells( 2, 10 ):Value := "Total"

Tamanho das colunas:
oSheet:Columns(1):ColumnWidth := 3.86
oSheet:Columns(2):ColumnWidth := 40
oSheet:Columns(3):ColumnWidth := 40
oSheet:Columns(4):ColumnWidth := 7
oSheet:Columns(5):ColumnWidth := 6.43

Tamanho da letra e Negrito: 
oSheet:Cells( 1, 1 ):Font:Size := 14
oSheet:Cells( 1, 1 ):Font:Bold := .T.
oSheet:Cells( 2, 1 ):Font:Size := 10

Alinhamento das células
oSheet:Cells( 1, 1 ):HorizontalAlignment:= -4108 //Centro
oSheet:Cells( 1, 2 ):HorizontalAlignment:= -4131 //Esquerda
oSheet:Cells( 1, 3 ):HorizontalAlignment:= -4152 //Direita
oSheet:Range("A2:M2"):HorizontalAlignment:= -4131 //Esquerda de A2 até M2

Mesclar células 
oSheet:Range("A1:M1"):Merge()

Escolher fonte de letra:
oSheet:Cells:Font:Name := "Times New Roman"
oSheet:Cells:Font:Size := 9

Formatar célula:
oSheet:Cells( 1, 5 ):Set( "NumberFormat", "#.##0,00" )

Cor da letra:
oSheet:Cells( 1, 1 ):Font:ColorIndex := 3

Cor de Preenchimento:
oSheet:Cells( 1, 2 ):Interior:ColorIndex := 7

Tabela de cores básicas:
Preto = 1
Branco = 2
Azul = 5
Azul Claro = 41
Azul Escuro = 11
Verde = 10
Vermelho = 3
Amarelo = 6
Marron = 53
Violeta = 13
Laranja = 46
Rosa = 7

Colocar Bordas:
oSheet:Range("A2:M10"):Borders(1):LineStyle:= 1
oSheet:Range("A2:M10"):Borders(2):LineStyle:= 1
oSheet:Range("A2:M10"):Borders(3):LineStyle:= 1
oSheet:Range("A2:M10"):Borders(4):LineStyle:= 1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...