Share via


How to create new Excel file and write to it using openXML in powershell

Question

Thursday, February 28, 2019 11:50 AM

I'm trying to create new .xlsx file and write to it using openXML.

i have found reference for Reading the excel through openXML but not for Writing to it. 

kindly Do the needful.

Thanks in Advance.

All replies (8)

Friday, March 1, 2019 7:13 AM

https://community.spiceworks.com/how_to/137203-create-an-excel-file-from-within-powershell

http://www.ericwhite.com/blog/integrating-open-xml-functionality-in-a-powershell-script-by-using-managed-code-via-the-add-type-cmdlet/

Just do it.


Friday, March 1, 2019 7:20 AM

Easiest method is:

Install-Module ImportExcel

Simple examples: https://jamesone111.wordpress.com/2017/12/05/using-the-import-excel-part-1-importing/

\(ツ)_/


Tuesday, March 5, 2019 1:49 PM

hi jrv,

thanks for ur reference.

In my client system, they dont have ms office installed. without install excel, we have to do that task. i have found reference to do in Visual studio C#.

but not for powershell?

so kindly drive me to it.

thanks in advance.


Tuesday, March 5, 2019 1:55 PM

hi leeseenli 

thanks for ur reference.

Need reference for writing in excel using openXML in powershell.

so kindly drive me to it.

thanks in advance.


Tuesday, March 5, 2019 1:56 PM

I guess you are going to need to learn PowerShell.

Download the module I posted and read the help.

I posted an example.

Do NOT use OpenXML.  It will be too much of an issue if you are not a programmer. 

If you really must use OpenXML then you will need to learn how to program with PowerShell and complex Net APIs.

\(ツ)_/


Tuesday, March 5, 2019 1:57 PM

You can also try PsExcel.

Import-Module PsExcel

https://github.com/RamblingCookieMonster/PSExcel

\(ツ)_/


Tuesday, March 5, 2019 2:01 PM

Also PowerShell Tools has OpenXML support:

https://github.com/EricWhiteDev/Open-Xml-PowerTools

\(ツ)_/


Tuesday, March 5, 2019 2:04 PM

hi,

thanks for your reference.

will look into it.