Added example

This commit is contained in:
dfinke
2017-06-15 19:43:54 -04:00
parent 822e63a667
commit b33223460e
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
Clear-Host
Import-Module .\ImportExcel.psd1 -Force
#ConvertFrom-ExcelToSQLInsert People .\testSQLGen.xlsx
ConvertFrom-ExcelData .\testSQLGen.xlsx {
param($propertyNames, $record)
$reportRecord = @()
foreach ($pn in $propertyNames) {
$reportRecord += "{0}: {1}" -f $pn, $record.$pn
}
$reportRecord +=""
$reportRecord -join "`r`n"
}
return
ConvertFrom-ExcelData .\testSQLGen.xlsx {
param($propertyNames, $record)
$ColumnNames = "'" + ($PropertyNames -join "', '") + "'"
$values = foreach ($propertyName in $PropertyNames) { $record.$propertyName }
$targetValues = "'" + ($values -join "', '") + "'"
"INSERT INTO People ({0}) Values({1});" -f $ColumnNames, $targetValues
}

Binary file not shown.