mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
PassThru example
This commit is contained in:
23
Examples/PassThru/TryPassThru.ps1
Normal file
23
Examples/PassThru/TryPassThru.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
$file = "sales.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$xlPkg = Import-Csv .\sales.csv | Export-Excel $file -PassThru
|
||||
|
||||
$ws = $xlPkg.Workbook.WorkSheets[1]
|
||||
|
||||
$ws.Cells["E1"].Value = "TotalSold"
|
||||
$ws.Cells["F1"].Value = "Add 10%"
|
||||
|
||||
2..($ws.Dimension.Rows) |
|
||||
ForEach {
|
||||
$ws.Cells["E$_"].Formula = "=C$_+D$_"
|
||||
$ws.Cells["F$_"].Formula = "=E$_+(10%*(C$_+D$_))"
|
||||
}
|
||||
|
||||
$ws.Cells.AutoFitColumns()
|
||||
|
||||
$xlPkg.Save()
|
||||
$xlPkg.Dispose()
|
||||
|
||||
Invoke-Item $file
|
||||
26
Examples/PassThru/sales.csv
Normal file
26
Examples/PassThru/sales.csv
Normal file
@@ -0,0 +1,26 @@
|
||||
"Region","Item","UnitSold","UnitCost"
|
||||
"South","Banana","54","0.46"
|
||||
"West","Banana","74","0.56"
|
||||
"West","Apple","26","0.7"
|
||||
"East","Banana","38","0.26"
|
||||
"East","Kale","71","0.69"
|
||||
"East","Apple","35","0.55"
|
||||
"East","Potato","48","0.48"
|
||||
"West","Banana","59","0.49"
|
||||
"West","Potato","56","0.62"
|
||||
"North","Apple","40","0.68"
|
||||
"South","Pear","39","0.44"
|
||||
"West","Banana","60","0.64"
|
||||
"West","Pear","32","0.29"
|
||||
"North","Kale","55","0.35"
|
||||
"West","Apple","73","0.26"
|
||||
"South","Potato","33","0.46"
|
||||
"West","Banana","49","0.59"
|
||||
"West","Pear","65","0.35"
|
||||
"North","Banana","33","0.31"
|
||||
"East","Kale","41","0.74"
|
||||
"South","Banana","49","0.31"
|
||||
"West","Apple","60","0.34"
|
||||
"South","Apple","38","0.59"
|
||||
"North","Pear","29","0.74"
|
||||
"West","Kale","67","0.38"
|
||||
|
Reference in New Issue
Block a user