Solved

How to convert and xlsx spreadsheet into CSV ?

Posted on 2013-01-15
10
4,994 Views
Last Modified: 2013-01-15
Hello,

How can I convert and xlsx spreadsheet into CSV ?

Thanks,
0
Comment
Question by:namerg
10 Comments
 
LVL 11

Expert Comment

by:BillBondo
ID: 38780151
Do a file save as other formats and choose csv.
0
 

Author Comment

by:namerg
ID: 38780232
jajajaj....buuu in Powershell ?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38780331
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 9

Expert Comment

by:David Carr
ID: 38780341
Try the following for a single file

# Excel file to convert
$xls = "C:\file1.xls";
# csv file to create
$csv = "C:\file1.csv";
 
Get-Content -Path $xls | Export-CSV -Path $csv -NoTypeInformation;
0
 

Author Comment

by:namerg
ID: 38780351
Hmm,

I have the following code and it pops up a window to Save As
$ExcelWB = new-object -comobject excel.application
$Workbook = $ExcelWB.Workbooks.Open("C:\scripts\AD\temp\10-22-2012.xlsx") 
$Workbook.SaveAs("C:\scripts\AD\temp\10-22-2012_Test.csv",6)
$ExcelWB.quit()

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
ID: 38780375
Try..
$File = "C:\user1.xlsx"
$savePath = "C:\Result.csv"
$objExcel = New-Object -ComObject Excel.Application
$objworkbook=$objExcel.Workbooks.Open($File)
$objworkbook.SaveAs($savePath,6)
$objworkbook.Close($false)
$objExcel.Quit()
Import-Csv -Path $savePath

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38780402
In your code you need to close the workbook before exiting the excel application..
$ExcelWB = new-object -comobject excel.application
$Workbook = $ExcelWB.Workbooks.Open("C:\Users\Pinky\Desktop\user1.xlsx") 
$Workbook.SaveAs("C:\Users\Pinky\Desktop\user1.csv",6)
$Workbook.Close($false)
$ExcelWB.quit()

Open in new window

0
 

Author Comment

by:namerg
ID: 38780407
Almost Perfect, it does create the CSV but it display the contents on the xlsx or csv in the console while running the script.

Last Name               : Gilles
First Name              : Elisabeth
Dept Descrip            : 1.A6300 - AR Resolution
Social Security Numbers : XXXXXXXXX
Employment Category     : F
Job Title               : AcctsReceivableSpecialist
Work Phone              : 303303456
Room                    :
Clock Number            : 2780
Date Of Birth           : 9/9/1980
Div Descrip             : Administration

Open in new window

0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 500 total points
ID: 38780420
Remove Import-Csv -Path $savePath.. It's the line which displays the result..
0
 

Author Comment

by:namerg
ID: 38780435
Love Subsun. You da man. Thanks a lot.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question