How do I convert a CSV file to XLSX file

I have a form that clients use to upload a CSV file.
After the file is uploaded I want to convert that file to an Excel 2007 spreadsheet and save it on the server.
I am using visual studio 2008 and office 2007.
mackeyrjAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

patrickabCommented:
mackeyrj,
I suggest two alternatives:
1. Import the CSV into Excel and save it as an xlsx file
or
2. Use ConvertXLS from Softinterface.com which has a specific option to do what you want.
Patrick
0
mackeyrjAuthor Commented:
I want the action to be handled programmatically inside the web application.
The client uploads the CSV and it just automatically is saved in the xlsx.
0
markpalinuxCommented:
I was looking for the same answer. I am looking to use vbscript.

Here is the cut and pasted for some web pages solution I came up with.

Works for me with vbscript. Hope this helps.

Mark
strCSVFile = "C:\me\code\vbscript-excel-csv-saveas\file1.csv"
strXLSX = "C:\me\code\vbscript-excel-csv-saveas\file1.xlsx"
 
 ' Create the Excel application.
    Set objExcel = CreateObject("Excel.Application")
 
    ' Uncomment this line to make Excel visible.
    'objExcel.Visible = True
 
    ' Load the CSV file.
    objExcel.Workbooks.Open (strCSVFile)
        
 
 ' Save as an Excel spreadsheet.
 
    objExcel.ActiveWorkbook.SaveAs strXLSX, 51
    'to get the file type look at EE Q_22879330
 
 
    ' Comment the rest of the lines to keep
    ' Excel running so you can see it.
 
    ' Close the workbook without saving.
    objExcel.ActiveWorkbook.Close False
 
    ' Close Excel.
    objExcel.Quit
    Set objExcel = Nothing

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mackeyrjAuthor Commented:
I had to make a few minor changes for this to work in VB 2008.

In the snippet notice the DIM AS  STRINGS and OBJECT that I added.


DIM strCSVFile AS STRING= "C:\me\code\vbscript-excel-csv-saveas\file1.csv"
DIM strXLSX AS STRING = "C:\me\code\vbscript-excel-csv-saveas\file1.xlsx"
 
 ' Create the Excel application.
    DIM objExcel AS OBJECT = CreateObject("Excel.Application")
 
    ' Uncomment this line to make Excel visible.
     objExcel.Visible = True
 
    ' Load the CSV file.
    objExcel.Workbooks.Open (strCSVFile)
        
 
 ' Save as an Excel spreadsheet.
 
    objExcel.ActiveWorkbook.SaveAs strXLSX, 51
    'to get the file type look at EE Q_22879330
 
 
    ' Comment the rest of the lines to keep
    ' Excel running so you can see it.
 
    ' Close the workbook without saving.
    objExcel.ActiveWorkbook.Close False
 
    ' Close Excel.
    objExcel.Quit
    Set objExcel = Nothing

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.