
There must be a way to automate this…Īnd, there is. This is very useful if you only have to deal with one or a few records that you need to import into PDF forms, but what if we are talking about 10s or 100s of records? It gets a bit boring to click on the same buttons again and again.

You can find this information here: Can I import data from an Excel spreadsheet to a fillable PDF Form? $ while ago I documented for how to manually import an Excel data record into a PDF form. $collected = $file.data|ogv -pass thru #this is a neat way to select some rows you want $om_excel() #This is where we actually pull from excel $file.filename = "c:\folder\file.xls" #can set this independently, useful for validation and troubleshooting $file.worksheet_index = "January" # Default: 1 can be a sheet index or sheet name $file.indexer_column = 5 # Default: 1 (first column) This column's contents will set the minimum number of rows, use if there are blank rows in your file but more data after them $file.header_contains="First Name" # if included it will drop everything before the first line that contains this, useful if there are instructions for humans in the worksheet $file = New-Module -AsCustomObject -ScriptBlock $file_template Write-host "Store Email: $($row."Store Email")" Write-host "Store: $($row."Store Number")"


$Store1Email = $file.data."Store Email" #first row, column named "Store Email" $Store1 = $file.data."Store Number" #first row, column named "Store Number" Your example: $file = New-Module -AsCustomObject -ScriptBlock $file_template

The above answers usually work, but I just had a project with excel datasheets that caused some problems.Įdit: Here's a much more advanced version that will pull it into an object, can handle blank and duplicate column names, and can skip human information at the beginning of the worksheet by looking for something in the header row.
