mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
fix naming consitency (case mostly)
This commit is contained in:
@@ -7,6 +7,6 @@ Remove-Item $xlSourcefile -ErrorAction Ignore
|
||||
#Put some simple data in a worksheet and Get an excel package object to represent the file
|
||||
$excel = 1..10 | Export-Excel $xlSourcefile -PassThru
|
||||
#Add a new worksheet named 'NewSheet' and copying the sheet that was just made (Sheet1) to the new sheet
|
||||
Add-WorkSheet -ExcelPackage $excel -WorkSheetname "NewSheet" -CopySource $excel.Workbook.Worksheets["Sheet1"]
|
||||
Add-Worksheet -ExcelPackage $excel -WorkSheetname "NewSheet" -CopySource $excel.Workbook.Worksheets["Sheet1"]
|
||||
#Save and open in Excel
|
||||
Close-ExcelPackage -ExcelPackage $excel -Show
|
||||
|
||||
@@ -22,9 +22,9 @@ Set-ExcelRange -Range $sheet.Column(4) -HorizontalAlignment Right -NFormat "#
|
||||
Set-ExcelRange -Address $sheet.Row(1) -Bold -HorizontalAlignment Center
|
||||
|
||||
#Create a Red Data-bar for the values in Column D
|
||||
Add-ConditionalFormatting -WorkSheet $sheet -Address "D2:D1048576" -DataBarColor Red
|
||||
Add-ConditionalFormatting -Worksheet $sheet -Address "D2:D1048576" -DataBarColor Red
|
||||
# Conditional formatting applies to "Addreses" aliases allow either "Range" or "Address" to be used in Set-ExcelRange or Add-Conditional formatting.
|
||||
Add-ConditionalFormatting -WorkSheet $sheet -Range "G2:G1048576" -RuleType GreaterThan -ConditionValue "104857600" -ForeGroundColor Red
|
||||
Add-ConditionalFormatting -Worksheet $sheet -Range "G2:G1048576" -RuleType GreaterThan -ConditionValue "104857600" -ForeGroundColor Red
|
||||
|
||||
foreach ($c in 5..9) {Set-ExcelRange -Address $sheet.Column($c) -AutoFit }
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ $data = $(
|
||||
New-PSItem Westerly 120
|
||||
New-PSItem SouthWest 118
|
||||
)
|
||||
# in this example instead of doing $variable = New-Conditional text <parameters> .... ; Export-excel -conditionalText $variable <other parameters>
|
||||
# the syntax is used is Export-excel -conditionalText (New-Conditional text <parameters>) <other parameters>
|
||||
# in this example instead of doing $variable = New-Conditional text <parameters> .... ; Export-excel -ConditionalText $variable <other parameters>
|
||||
# the syntax is used is Export-excel -ConditionalText (New-Conditional text <parameters>) <other parameters>
|
||||
|
||||
|
||||
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType AboveAverage)
|
||||
|
||||
@@ -20,6 +20,6 @@ Dec,44,63,46
|
||||
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -AutoSize -Title "Monthly Temperatures" -PassThru
|
||||
|
||||
$sheet = $excel.Workbook.Worksheets["Sheet1"]
|
||||
Add-ConditionalFormatting -WorkSheet $sheet -Range "B1:D14" -DataBarColor CornflowerBlue
|
||||
Add-ConditionalFormatting -Worksheet $sheet -Range "B1:D14" -DataBarColor CornflowerBlue
|
||||
|
||||
Close-ExcelPackage $excel -Show
|
||||
@@ -14,7 +14,7 @@ Jun,621
|
||||
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -PassThru
|
||||
|
||||
$sheet = $excel.Workbook.Worksheets["Sheet1"]
|
||||
Add-ConditionalFormatting -WorkSheet $sheet -Range "B1:B7" -DataBarColor LawnGreen
|
||||
Add-ConditionalFormatting -Worksheet $sheet -Range "B1:B7" -DataBarColor LawnGreen
|
||||
|
||||
Set-ExcelRange -Address $sheet.Cells["A8"] -Value "Total"
|
||||
Set-ExcelRange -Address $sheet.Cells["B8"] -Formula "=Sum(Sales)"
|
||||
|
||||
@@ -39,7 +39,7 @@ $excelPackage = @('Chisel', 'Crowbar', 'Drill', 'Hammer', 'Nails', 'Saw', 'Screw
|
||||
|
||||
#region Creating a list using a PowerShell array
|
||||
$ValidationParams = @{
|
||||
WorkSheet = $excelPackage.sales
|
||||
Worksheet = $excelPackage.sales
|
||||
ShowErrorMessage = $true
|
||||
ErrorStyle = 'stop'
|
||||
ErrorTitle = 'Invalid Data'
|
||||
|
||||
@@ -16,9 +16,9 @@ $pkg = $data | Export-Excel -Path $f -AutoSize -PassThru
|
||||
|
||||
$ws = $pkg.Workbook.Worksheets["Sheet1"]
|
||||
|
||||
Set-ExcelRange -WorkSheet $ws -Range "A2:C6" -BackgroundColor PeachPuff -FontColor Purple -FontSize 12 -Width 12
|
||||
Set-ExcelRange -WorkSheet $ws -Range "D2:D6" -BackgroundColor WhiteSmoke -FontColor Orange -Bold -FontSize 12 -Width 12
|
||||
Set-ExcelRange -WorkSheet $ws -Range "A1:D1" -BackgroundColor BlueViolet -FontColor Wheat -FontSize 12 -Width 12
|
||||
Set-ExcelRange -WorkSheet $ws -Range "A:A" -Width 15
|
||||
Set-ExcelRange -Worksheet $ws -Range "A2:C6" -BackgroundColor PeachPuff -FontColor Purple -FontSize 12 -Width 12
|
||||
Set-ExcelRange -Worksheet $ws -Range "D2:D6" -BackgroundColor WhiteSmoke -FontColor Orange -Bold -FontSize 12 -Width 12
|
||||
Set-ExcelRange -Worksheet $ws -Range "A1:D1" -BackgroundColor BlueViolet -FontColor Wheat -FontSize 12 -Width 12
|
||||
Set-ExcelRange -Worksheet $ws -Range "A:A" -Width 15
|
||||
|
||||
Close-ExcelPackage -ExcelPackage $pkg -Show
|
||||
@@ -13,7 +13,7 @@ Timestamp,Tenant
|
||||
10/29/2018 3:01:40.989,1
|
||||
10/29/2018 3:01:50.545,1
|
||||
10/29/2018 3:02:00.999,1
|
||||
"@ | Select-Object @{n = 'Timestamp'; e = {get-date $_.timestamp}}, tenant, @{n = 'Bucket'; e = { - (get-date $_.timestamp).Second % 30}}
|
||||
"@ | Select-Object @{n = 'Timestamp'; e = {Get-date $_.timestamp}}, tenant, @{n = 'Bucket'; e = { - (Get-date $_.timestamp).Second % 30}}
|
||||
|
||||
$f = "$env:temp\pivottest.xlsx"
|
||||
Remove-Item $f -ErrorAction SilentlyContinue
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue
|
||||
|
||||
#Get a subset of services into $s and export them
|
||||
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property *
|
||||
[System.Collections.ArrayList]$s = Get-service | Select-Object -first 25 -Property *
|
||||
$s | Export-Excel -Path $env:temp\server1.xlsx
|
||||
|
||||
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue
|
||||
|
||||
#Get a subset of services into $s and export them
|
||||
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property Name,DisplayName,StartType
|
||||
[System.Collections.ArrayList]$s = Get-service | Select-Object -first 25 -Property Name,DisplayName,StartType
|
||||
$s | Export-Excel -Path $env:temp\server1.xlsx
|
||||
|
||||
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s.
|
||||
|
||||
@@ -17,7 +17,7 @@ function New-CellData {
|
||||
)
|
||||
|
||||
$setFormatParams = @{
|
||||
WorkSheet = $ws
|
||||
Worksheet = $ws
|
||||
Range = $Range
|
||||
NumberFormat = $Format
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ Set-Row -Worksheet $ws -Heading "Average" -Value {"=Average($columnName`2
|
||||
Set-Column -Worksheet $ws -Heading "WinsToPoles" -Value {"=D$row/C$row"} -Column 6 -AutoSize -AutoNameRange
|
||||
Set-Column -Worksheet $ws -Heading "WinsToFast" -Value {"=E$row/C$row"} -Column 7 -AutoSize -AutoNameRange
|
||||
|
||||
Set-ExcelRange -WorkSheet $ws -Range "F2:G50" -NumberFormat "0.0%"
|
||||
Set-ExcelRange -Worksheet $ws -Range "F2:G50" -NumberFormat "0.0%"
|
||||
$chart = New-ExcelChart -NoLegend -ChartType XYScatter -XRange WinsToFast -YRange WinsToPoles -Column 7 -Width 2000 -Height 700 -Title "Poles vs fastlaps"
|
||||
Export-Excel -ExcelPackage $Excel -WorkSheetname "Winners" -ExcelChartDefinition $chart -Show
|
||||
@@ -15,7 +15,7 @@ $excel = $data | Export-Excel $xlfile -Passthru -AutoSize -TableName SalesByQuar
|
||||
|
||||
$ws = $excel.Sheet1
|
||||
|
||||
Set-ExcelRange -WorkSheet $ws -Range "B2:E5" -NumberFormat "$#,##0" -AutoSize
|
||||
Set-ExcelRange -Worksheet $ws -Range "B2:E5" -NumberFormat "$#,##0" -AutoSize
|
||||
$sparkLineType = "line"
|
||||
$null = $ws.SparklineGroups.Add( $sparkLineType, $ws.Cells["F2"], $ws.Cells["B2:E2"] )
|
||||
$null = $ws.SparklineGroups.Add( $sparkLineType, $ws.Cells["F3"], $ws.Cells["B3:E3"] )
|
||||
|
||||
@@ -41,8 +41,8 @@ Remove-Item $xlfile -ErrorAction SilentlyContinue
|
||||
$excel = $data | Export-Excel $xlfile -WorksheetName SEKRates -AutoSize -PassThru
|
||||
|
||||
# Add a column sparkline for all currencies
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range "A2:A12" -NumberFormat "yyyy-mm-dd" -AutoSize
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range A15 -Value Column -AutoSize
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range "A2:A12" -NumberFormat "yyyy-mm-dd" -AutoSize
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range A15 -Value Column -AutoSize
|
||||
|
||||
$sparklineCol = $excel.SEKRates.SparklineGroups.Add(
|
||||
"Column",
|
||||
@@ -54,7 +54,7 @@ $sparklineCol.High = $true
|
||||
$sparklineCol.ColorHigh.SetColor("Red")
|
||||
|
||||
# Add a line sparkline for all currencies
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range A16 -Value Line -AutoSize
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range A16 -Value Line -AutoSize
|
||||
$sparklineLine = $excel.SEKRates.SparklineGroups.Add(
|
||||
"Line",
|
||||
$excel.SEKRates.Cells["B16:Q16"],
|
||||
@@ -64,7 +64,7 @@ $sparklineLine = $excel.SEKRates.SparklineGroups.Add(
|
||||
$sparklineLine.DateAxisRange = $excel.SEKRates.Cells["A2:A12"]
|
||||
|
||||
# Add some more random values and add a stacked sparkline.
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range A17 -Value Stacked -AutoSize
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range A17 -Value Stacked -AutoSize
|
||||
|
||||
$numbers = 2, -1, 3, -4, 8, 5, -12, 18, 99, 1, -4, 12, -8, 9, 0, -8
|
||||
|
||||
@@ -86,7 +86,7 @@ $sparklineStacked.ColorLow.SetColor("Green")
|
||||
$sparklineStacked.Negative = $true
|
||||
$sparklineStacked.ColorNegative.SetColor("Blue")
|
||||
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range "A15:A17" -Bold -Height 50 -AutoSize
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range "A15:A17" -Bold -Height 50 -AutoSize
|
||||
|
||||
$v = @"
|
||||
High - Red
|
||||
@@ -94,6 +94,6 @@ Low - Green
|
||||
Negative - Blue
|
||||
"@
|
||||
|
||||
Set-ExcelRange -WorkSheet $excel.SEKRates -Range S17 -Value $v -WrapText -Width 20 -HorizontalAlignment Center -VerticalAlignment Center
|
||||
Set-ExcelRange -Worksheet $excel.SEKRates -Range S17 -Value $v -WrapText -Width 20 -HorizontalAlignment Center -VerticalAlignment Center
|
||||
|
||||
Close-ExcelPackage $excel -Show
|
||||
@@ -5,7 +5,7 @@ function ConvertTo-PesterTest {
|
||||
$WorksheetName = 'Sheet1'
|
||||
)
|
||||
|
||||
$testFileName = "{0}.tests.ps1" -f (get-date).ToString("yyyyMMddHHmmss")
|
||||
$testFileName = "{0}.tests.ps1" -f (Get-date).ToString("yyyyMMddHHmmss")
|
||||
|
||||
$records = Import-Excel $XlFilename
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ function Test-APIReadXls {
|
||||
$WorksheetName = 'Sheet1'
|
||||
)
|
||||
|
||||
$testFileName = "{0}.tests.ps1" -f (get-date).ToString("yyyyMMddHHmmss")
|
||||
$testFileName = "{0}.tests.ps1" -f (Get-date).ToString("yyyyMMddHHmmss")
|
||||
|
||||
$records = Import-Excel $XlFilename
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ End Function
|
||||
$module = $wb.VbaProject.Modules.AddModule("PSExcelModule")
|
||||
$module.Code = $code
|
||||
|
||||
Set-ExcelRange -WorkSheet $sheet -Range "h7" -Formula "HelloWorld()" -AutoSize
|
||||
Set-ExcelRange -WorkSheet $sheet -Range "h8" -Formula "DoSum()" -AutoSize
|
||||
Set-ExcelRange -Worksheet $sheet -Range "h7" -Formula "HelloWorld()" -AutoSize
|
||||
Set-ExcelRange -Worksheet $sheet -Range "h8" -Formula "DoSum()" -AutoSize
|
||||
|
||||
Close-ExcelPackage $Excel -Show
|
||||
Reference in New Issue
Block a user