×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PowerShell save as xlsx without excel

PowerShell save as xlsx without excel

PowerShell save as xlsx without excel

(OP)
Hello All
I have a PowerShell script that takes a txt file that is output from our monitoring software sorts it by headers and converts it to a CSV file. my issue is that I need this file in xlsx format and I do not have Excel installed on the server. does anyone know of anyway to do this?

RE: PowerShell save as xlsx without excel

come on another separate post in the vbscript forum?
for example a family tree related csv
Import-csv yourfile.csv|select person, surname, given, gender|sort gender, surname,given|export-csv newfile.csv
open the csv in xl or rename it to xls..etc

RE: PowerShell save as xlsx without excel

You cannot merely rename a TEXT file to .xls* it's still a text file!

RE: PowerShell save as xlsx without excel

dpierce4776,

I am not aware of any way to do the conversion you are looking for without having Excel installed. Microsoft provides a free Excel viewer that would allow you to read an Excel file without having Excel installed, but nothing to let you go the other way.

What you could however do is use a remote PowerShell session to a system that does have Excel installed, have that system open the CSV file and then perform the SaveAs to convert it.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: PowerShell save as xlsx without excel

(OP)
Thank you markdmac
I have been researching it and seen others try to make cmdlets for PowerShell to make it work but when I try it it errors out

RE: PowerShell save as xlsx without excel

dpierce4776, start with getting code to work locally on a machine that does have Excel. Then you just need to put the wrapper of the remote session around it.

Here is some quick code I put together and tested to verify it works locally for you.

CODE --> PowerShell

$xl = New-Object -ComObject Excel.Application
$xl.Visible = $True
$WorkBook = $xl.Workbooks.Open("C:\Temp\Printers.csv")
$xl.ActiveWorkBook.SaveAs("C:\Temp\Printers.xlsx") 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close