mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
Added Apply Style example
This commit is contained in:
24
Examples/FormatCellStyles/ApplyStyle.ps1
Normal file
24
Examples/FormatCellStyles/ApplyStyle.ps1
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
$data = ConvertFrom-Csv @'
|
||||||
|
Item,Quantity,Price,Total Cost
|
||||||
|
Footballs,9,21.95,197.55
|
||||||
|
Cones,36,7.99,287.64
|
||||||
|
Shin Guards,14,10.95,153.3
|
||||||
|
Turf Shoes,22,79.95,1758.9
|
||||||
|
Baseballs,68,7.99,543.32
|
||||||
|
Baseball Gloves,31,65.00,2015.00
|
||||||
|
Baseball Bats,38,159.00,6042.00
|
||||||
|
'@
|
||||||
|
|
||||||
|
$f = "$env:TEMP\styles.xlsx"
|
||||||
|
rm $f -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
$pkg = $data | Export-Excel -Path $f -AutoSize -PassThru
|
||||||
|
|
||||||
|
$ws = $pkg.Workbook.Worksheets["Sheet1"]
|
||||||
|
|
||||||
|
Set-Format -WorkSheet $ws -Range "A2:C6" -BackgroundColor PeachPuff -FontColor Purple -FontSize 12 -Width 12
|
||||||
|
Set-Format -WorkSheet $ws -Range "D2:D6" -BackgroundColor WhiteSmoke -FontColor Orange -Bold -FontSize 12 -Width 12
|
||||||
|
Set-Format -WorkSheet $ws -Range "A1:D1" -BackgroundColor BlueViolet -FontColor Wheat -FontSize 12 -Width 12
|
||||||
|
Set-Format -WorkSheet $ws -Range "A:A" -Width 15
|
||||||
|
|
||||||
|
Close-ExcelPackage -ExcelPackage $pkg -Show
|
||||||
Reference in New Issue
Block a user