Powershell script to insert new columns in excel

Hello,

I have an excel sheet which has 10 rows and 200 columns, i want to add columns in between those 200 columns, below every column i want to add 5 new columns, its similar to insert new column if we choose a column a right click and click insert, how can i achieve this in powershell

There are some Excel modules on PowerShell gallery.

Find-Module -Name *excel*

I have already used some of them but I don’t remember which one is doing what.

You must try them out…

You can use the famous ImportExcel module to manage excel files in PowerShell. To add columns, Iterate through the object and add more entries then export it using Export-Excel cmdlet.

You could also export it as a CSV and do the manipulation as a PSObject and export as CSV to avoid messing directly with Excel.