Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSV to EXCEL conversion
#1
Not Solved
Hi all

I am running csv to excel conversion code in QTP9.5 , the execution and results are fune except that some of the "date" field data in CSV is converted to "numbers" in excel.

Any comments or help is appreciated.

Many thanks in advance

below is the code I am using

'Function Name : CSV to excel
'Fucntion Description: 'VBScript to convert CSV file to Excel - number format issue
'Test data used : test data
'Date : 21/04/09
'Written by :
'*******************************************************************
Code:
Function csvtoexcel

Dim fldr, f, file,strOrigFile, strFile, fso, strDirectory
Dim objExcel

strOrigFile = "C:\QTPV6\results\actual\200906019043a.csv"
'******************************************************
'CONVERTS THE FILE TO AN EXCEL FILE
'******************************************************
Code:
strFile = replace(strOrigFile,".csv",".xls")

Set objExcel = CreateObject("Excel.Application")

objExcel.Workbooks.Open strOrigFile

objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strFile, -4143

objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Close
objExcel.DisplayAlerts = False
objExcel.Application.Quit

'******************************************************
'FORMAT THE EXCEL FILE AND SAVE IT
'******************************************************

Code:
objExcel.Workbooks.Open strFile

objExcel.columns("A:A").numberformat="0"
objExcel.columns("C:C").numberformat="0"


objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strFile, -4143

objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Close
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing

End Function
Reply


Messages In This Thread
CSV to EXCEL conversion - by neerukonda9 - 10-22-2009, 08:32 PM
RE: CSV to EXCEL conversion - by venkatbatchu - 10-23-2009, 06:25 AM
RE: CSV to EXCEL conversion - by Saket - 10-23-2009, 10:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem With conversion function wajid 3 1,449 10-01-2018, 01:16 PM
Last Post: wajid
  How to update CSV File and need to Save same CSV File kotaramamohana 1 3,324 10-24-2015, 08:40 AM
Last Post: tigerliew
  Pdf to Excel or any other Format Conversion branjitk 1 2,335 06-14-2012, 08:14 AM
Last Post: basanth27
  Working with .csv Files pjeigenn 0 1,720 08-02-2010, 07:15 PM
Last Post: pjeigenn

Forum Jump:


Users browsing this thread: 1 Guest(s)