Ir ao conteúdo
  • Cadastre-se

Converter arquivo Excel em CSV


wawaanjo

Posts recomendados

Srs.

Preciso carregar uma tabela no Oracle a partir de um arquivo csv.

Na verdade, tenho uma planilha Excel e a partir dessa planilha, vou em 'Salvar Como' e salvo no formato csv (Separado por virgulas).

Mas na minha tabela tenho um campo Data no Formato: DD/MM/YYYY HH24:MI:SS (Dia/Mês/Ano Hora: Minuto e Segundo) - (02/10/2013 16:23:15)

O Problema é que quando salvo essa planilha no formato csv, depois que abro o arquivo, esse campo data some os segundos. (02/10/2013 16:23)

Alguém sabe o que ocorre??

Link para o comentário
Compartilhar em outros sites

Boa noite!!

Tente assim...

Sub CreateCSV()
Dim rCell As Range
Dim rRow As Range
Dim vaColPad As Variant
Dim i As Long
Dim sOutput As String
Dim sFname As String, lFnum As Long

Const sDELIM As String = ";"

'Required width of columns
vaColPad = Array(0, 0, 6, 0, 4)
i = LBound(vaColPad)

'Open a text file to write
sFname = "C:\Documents and Settings\User\Desktop\Test.csv" 'Local onde o arquivo será salvo
lFnum = FreeFile

Open sFname For Output As lFnum

'Loop through the rows
For Each rRow In Sheets("Plan1").UsedRange.Rows 'Nome da guia
'Loop through the cells in the rows
If Len(rRow.Cells(1, 1).Value) > 0 Then
For Each rCell In rRow.Cells
'If the cell value is less than required, then pad
'it with zeros, else just use the cell value

'If Len(rCell.Value) < vaColPad(i) Then
'sOutput = sOutput & Application.Rept(0, _
'vaColPad(i) & Len(rCell.Value)) & rCell.Value & sDELIM
'Else
sOutput = sOutput & rCell.Value & sDELIM '(this value generates an extra delimiter at the end of every line).
'End If
'i = i + 1
Next rCell
'remove the last comma
sOutput = Left(sOutput, Len(sOutput) - 1)

'write to the file and reinitialize the variables
Print #lFnum, sOutput
sOutput = ""
'i = LBound(vaColPad)
End If
Next rRow

'Close the file
Close lFnum

End Sub

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...