Powershell script to insert new columns in excel

Welcome Forums General PowerShell Q&A Powershell script to insert new columns in excel

This topic contains 3 replies, has 4 voices, and was last updated by

1 week, 1 day ago.

  • Author
  • #133029

    Points: 11
    Rank: Member


    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

  • #133050

    Points: 168
    Helping Hand
    Rank: Participant

    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...

  • #133097

    Points: 1,086
    Helping Hand
    Rank: Community Hero

    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.

  • #133329

    Points: 427
    Helping Hand
    Rank: Contributor

    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.

You must be logged in to reply to this topic.