powershell command or batch file to clear excel file contents

I need help to create a powershell batch file or command to clear a set of excel files without opening them.

clear-content seems to clear content of notepads but is corrupting excel files.

please help

No Data
  • Not possible for any file type.

    Reading a file means opening the file, Excel or not. Yet, if you mean not having to run Excel.exe, that is a different thing, for with Excel depending on how they were built are just text files and you can use the normal Powershell file management cmdlets to deal with what you are after.

    Otherwise, you need to have no other choice but to start Excel.exe to manipulate the .xls/xlxs file and there are plenty of articles all over the web on working with Excel or any other Office app with PowerShell. Search for that.

    There are videos on Youtube, MSDN Channel 9, MS techcommunity on this PowerShell and Excel as well as additional modules in the MS powershellgallery.com to help.

    Find-Module -Name '*Excel*' | 
    Format-Table -AutoSize
    # Results
    Version     Name                          Repository Description                                                                                               
    -------     ----                          ---------- -----------                                                                                               
    7.0.1       ImportExcel                   PSGallery  PowerShell module to import/export Excel spreadsheets, without Excel....                                  
    0.1.5       PSWriteExcel                  PSGallery  Little project to create Excel files without Microsoft Excel being installed.                             
    1.0.2       PSExcel                       PSGallery  Work with Excel without installing Excel                                                                  
    19.0.7354.0 ExcelCmdlets                  PSGallery  CData Cmdlets for Excel                                                                                   
    19.0.7354.0 ExcelServicesCmdlets          PSGallery  CData Cmdlets for Excel Services                                                                          
    0.1.6       BitTitan.Runbooks.Excel       PSGallery  PowerShell module for Excel-related functions and resources used in BitTitan Runbooks                     
    0.6.9       ExcelPSLib                    PSGallery  Allow simple creation and manipulation of XLSX file                                                       
    19.0.7354.0 ExcelOnlineCmdlets            PSGallery  CData Cmdlets for Excel Online                                                                            
    0.1.6       BitTitan.Runbooks.Excel.Beta  PSGallery  PowerShell module for Excel-related functions and resources used in BitTitan Runbooks                     
    0.0.4       Excelimo                      PSGallery  Simple project generating Excel Workbooks/Worksheets                                                      
    0.0.1       ProductivityTools.PSExcel2SQL PSGallery  Module takes all excel files in given directory and push the content to database.  

    You need to show your work for folks to be willing to help you, otherwise, you are asking folks to do your work for you, and they are not inclined to do that. Not showing your work will get you banned, downvoted, ignore, etc.

No Data