Quantcast
Viewing all articles
Browse latest Browse all 175326

Merging Excel file

Hello,

 

Can someone please tell me how

 

I am using the below script to merge excel file, got from LucD

script is working for the first 10 excel files but not working for another set.

 

$sourceFolderPath = "D:\Consolidated\2"

$XLfiles = Get-ChildItem $sourceFolderPath -Filter *.xlsx

foreach ($XLfile in $XLfiles) {

       Import-Excel $XLfile.FullName | Export-Excel $OutputFilePath -WorksheetName $XLfile.BaseName  

}

Set-PSRepository cmdlet

 

This is the error I am getting :

 

Failed importing the Excel workbook 'D:\RVTool\Consolidated\2\Test.xlsx' with worksheet '': Duplicate column headers found on row '1' in columns '70 71'. Column headers must be unique, if this

is not a requirement please use the '-NoHeader' or '-HeaderName' parameter.

At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.1.1\Public\Import-Excel.ps1:216 char:21

+ ...     catch { throw "Failed importing the Excel workbook '$Path' with w ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (Failed importin...ame' parameter.:String) [], RuntimeException

    + FullyQualifiedErrorId : Failed importing the Excel workbook 'D:\RVTool\Consolidated\2\Test.xlsx' with worksheet '': Duplicate column headers found on row '1' in columns '70 71'. Column he

   aders must be unique, if this is not a requirement please use the '-NoHeader' or '-HeaderName' parameter.


Viewing all articles
Browse latest Browse all 175326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>