Solved

How to convert and xlsx spreadsheet into CSV ?

Posted on 2013-01-15
10
5,079 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DFS issue 3 26
Need HTML output in powershell line by line 3 30
Find computer name from username 9 51
output of netstat -r in Powersshell HTML 3 28
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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