mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added example
This commit is contained in:
28
Examples/ConvertFrom/ConvertFrom.ps1
Normal file
28
Examples/ConvertFrom/ConvertFrom.ps1
Normal 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
|
||||||
|
}
|
||||||
BIN
Examples/ConvertFrom/testSQLGen.xlsx
Normal file
BIN
Examples/ConvertFrom/testSQLGen.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user