• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5743
  • Last Modified:

How to convert and xlsx spreadsheet into CSV ?

Hello,

How can I convert and xlsx spreadsheet into CSV ?

Thanks,
0
namerg
Asked:
namerg
2 Solutions
 
BillBondoCommented:
Do a file save as other formats and choose csv.
0
 
namergSystems AdministratorAuthor Commented:
jajajaj....buuu in Powershell ?
0
 
SubsunCommented:
0
Problems using Powershell and Active Directory?

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

 
David CarrCommented:
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
 
namergSystems AdministratorAuthor Commented:
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
 
SubsunCommented:
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
 
SubsunCommented:
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
 
namergSystems AdministratorAuthor Commented:
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
 
SubsunCommented:
Remove Import-Csv -Path $savePath.. It's the line which displays the result..
0
 
namergSystems AdministratorAuthor Commented:
Love Subsun. You da man. Thanks a lot.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now