Click here to Skip to main content
15,067,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a csv file and then trying to put it in an existing excel file

While executing getting the below error. it is generating the csv

csv data


Add-Worksheet : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its 
properties do not match any of the parameters that take pipeline input.
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.2.2\Public\Export-Excel.ps1:129 char:26
+             $ws = $pkg | Add-Worksheet @params
+                          ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (OfficeOpenXml.ExcelPackage:PSObject) [Add-Worksheet], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Add-Worksheet
Could not get worksheet Index
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.2.2\Public\Export-Excel.ps1:135 char:16
+         catch {throw "Could not get worksheet $WorksheetName"}
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Could not get worksheet Index:String) [], RuntimeException
    + FullyQualifiedErrorId : Could not get worksheet Index

Please let me know what is the issue with this line

Import-Csv -Path "E:\Index.csv" | Export-Excel -Path "E:\ipaddress.xlsx" -WorkSheetname 'Index' -MoveToStart

What I have tried:

foreach($data in $WorkSheetNames)
    $obj = New-Object PSObject
    $final_data ="=HYPERLINK(`"#" + $data + "!A" +$count + """"+ "," + """" + "$data" + """)"

    if($final_data -match "Index")
    Add-Member -InputObject $obj -MemberType NoteProperty -Name "Index" -Value $final_data
    $table +=$obj
$table | Export-Csv -Path "E:\Index.csv" -Append -NoTypeInformation
Import-Csv -Path "E:\Index.csv" | Export-Excel -Path "E:\ipaddress.xlsx" -WorkSheetname 'Index' -MoveToStart
Richard MacCutchan 13-Aug-21 9:40am
The error message suggests a parameter is missing. Check the documentation or help for both the Import-Csv and Export-Excel cmdlets.
Empty Coder 13-Aug-21 11:42am
That's what i am not able to figure it out what is missing. it worked previously but suddenly stopped working. havn't done any changes
Richard MacCutchan 13-Aug-21 11:55am
Sorry, I have not used that package, so have no idea what parameters, or what format data, it requires.
You could try just running the Import-Csv cmdlet to see if the data is in the correct format
Empty Coder 13-Aug-21 12:00pm
Import-csv is fine. it is generating the data as mentioned in the question. issue is with the Export-Excel part.
Richard MacCutchan 13-Aug-21 12:32pm
Is there a home site for it that might help?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900