A
A
Alexey Kupreichik2016-10-17 16:29:34
excel
Alexey Kupreichik, 2016-10-17 16:29:34

How to convert .csv file to .xlsx format in VBScript?

Straight to the point. There is a text file (table) in .csv format. ";" are used as column separators. (semicolon), for example:

Column 1.1;Column 1.2;...;Column 1.N
Column 2.1;Column 2.2;...;Column 2.N

How can I convert this file to .xlsx format using VBScript?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#algooptimize #bottize, 2016-10-18
@user004

powershell

#Write-Host "Hello" -BackgroundColor Black -ForegroundColor Yellow
$objExcel = New-Object -ComObject Excel.Application
#$o = $objExcel
#$o | Get-Member
#$o.Workbooks | Get-Member
#$objExcel.Workbooks | Select-Object -Debug -Property "OpenText"

$objExcel.Workbooks.OpenText( "z:\dev\ps\1.csv", # file to open
         [Microsoft.Office.Interop.Excel.XlPlatform]::xlWindows, 
         1, # start from row 1
         [Microsoft.Office.Interop.Excel.XlTextParsingType]::xlDelimited,
         [Microsoft.Office.Interop.Excel.XlTextQualifier]::xlTextQualifierDoubleQuote,
         $false, # Consecutive Delimiter
         $false, # tab
         $false, # semicolon
         $false, # comma
         $false, # space
         $true,  # use other
         ';')

$book = $objExcel.Workbooks[1]
$book.SaveAs("z:\dev\ps\1.xlsx", [Microsoft.Office.Interop.Excel.XlFileFormat]::xlWorkbookDefault)

$book.Close($false)

$objExcel.Quit()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question