mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Initial commit, date conditional formatting
This commit is contained in:
14
Examples/ConditionalFormatting/CodeGenExamples.ps1
Normal file
14
Examples/ConditionalFormatting/CodeGenExamples.ps1
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
echo Last7Days LastMonth LastWeek NextMonth NextWeek ThisMonth ThisWeek Today Tomorrow Yesterday |
|
||||||
|
% {
|
||||||
|
$text = @"
|
||||||
|
`$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm `$f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel `$f -Show -AutoSize -ConditionalText `$(
|
||||||
|
New-ConditionalText -ConditionalType $_
|
||||||
|
)
|
||||||
|
"@
|
||||||
|
$text | Set-Content -Encoding Ascii "Highlight-$($_).ps1"
|
||||||
|
}
|
||||||
26
Examples/ConditionalFormatting/FormatCalculations.ps1
Normal file
26
Examples/ConditionalFormatting/FormatCalculations.ps1
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
$data = $(
|
||||||
|
|
||||||
|
New-PSItem North 111 (echo Region Amount )
|
||||||
|
New-PSItem East 111
|
||||||
|
New-PSItem West 122
|
||||||
|
New-PSItem South 200
|
||||||
|
|
||||||
|
New-PSItem NorthEast 103
|
||||||
|
New-PSItem SouthEast 145
|
||||||
|
New-PSItem SouthWest 136
|
||||||
|
New-PSItem South 127
|
||||||
|
|
||||||
|
New-PSItem NorthByNory 100
|
||||||
|
New-PSItem NothEast 110
|
||||||
|
New-PSItem Westerly 120
|
||||||
|
New-PSItem SouthWest 118
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType AboveAverage)
|
||||||
|
$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType BelowAverage)
|
||||||
|
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType TopPercent)
|
||||||
22
Examples/ConditionalFormatting/GenDates.ps1
Normal file
22
Examples/ConditionalFormatting/GenDates.ps1
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
function Get-DateOffset {
|
||||||
|
param($days=0)
|
||||||
|
|
||||||
|
(Get-Date).AddDays($days).ToShortDateString()
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-Number {
|
||||||
|
Get-Random -Minimum 10 -Maximum 100
|
||||||
|
}
|
||||||
|
|
||||||
|
New-PSItem (Get-DateOffset -7) (Get-Number) 'LastWeek,Last7Days,ThisMonth' (echo Date Amount Label)
|
||||||
|
New-PSItem (Get-DateOffset) (Get-Number) 'Today,ThisMonth,ThisWeek'
|
||||||
|
New-PSItem (Get-DateOffset -30) (Get-Number) LastMonth
|
||||||
|
New-PSItem (Get-DateOffset -1) (Get-Number) 'Yesterday,ThisMonth,ThisWeek'
|
||||||
|
New-PSItem (Get-DateOffset) (Get-Number) 'Today,ThisMonth,ThisWeek'
|
||||||
|
New-PSItem (Get-DateOffset -5) (Get-Number) 'LastWeek,Last7Days,ThisMonth'
|
||||||
|
New-PSItem (Get-DateOffset 7) (Get-Number) 'NextWeek,ThisMonth'
|
||||||
|
New-PSItem (Get-DateOffset 28) (Get-Number) NextMonth
|
||||||
|
New-PSItem (Get-DateOffset) (Get-Number) 'Today,ThisMonth,ThisWeek'
|
||||||
|
New-PSItem (Get-DateOffset -6) (Get-Number) 'LastWeek,Last7Days,ThisMonth'
|
||||||
|
New-PSItem (Get-DateOffset -2) (Get-Number) 'Last7Days,ThisMonth,ThisWeek'
|
||||||
|
New-PSItem (Get-DateOffset 1) (Get-Number) 'Tomorrow,ThisMonth,ThisWeek'
|
||||||
8
Examples/ConditionalFormatting/Highlight-Last7Days.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-Last7Days.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType Last7Days
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-LastMonth.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-LastMonth.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType LastMonth
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-LastWeek.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-LastWeek.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType LastWeek
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-NextMonth.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-NextMonth.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType NextMonth
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-NextWeek.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-NextWeek.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType NextWeek
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-ThisMonth.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-ThisMonth.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType ThisMonth
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-ThisWeek.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-ThisWeek.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType ThisWeek
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-Today.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-Today.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType Today
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-Tomorrow.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-Tomorrow.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType Tomorrow
|
||||||
|
)
|
||||||
8
Examples/ConditionalFormatting/Highlight-Yesterday.ps1
Normal file
8
Examples/ConditionalFormatting/Highlight-Yesterday.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
.\GenDates.ps1 |
|
||||||
|
Export-Excel $f -Show -AutoSize -ConditionalText $(
|
||||||
|
New-ConditionalText -ConditionalType Yesterday
|
||||||
|
)
|
||||||
23
Examples/ConditionalFormatting/HighlightDuplicates.ps1
Normal file
23
Examples/ConditionalFormatting/HighlightDuplicates.ps1
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
$f = ".\testExport.xlsx"
|
||||||
|
|
||||||
|
rm $f -ErrorAction Ignore
|
||||||
|
|
||||||
|
$data = $(
|
||||||
|
|
||||||
|
New-PSItem North 111 (echo Region Amount )
|
||||||
|
New-PSItem East 11
|
||||||
|
New-PSItem West 12
|
||||||
|
New-PSItem South 1000
|
||||||
|
|
||||||
|
New-PSItem NorthEast 10
|
||||||
|
New-PSItem SouthEast 14
|
||||||
|
New-PSItem SouthWest 13
|
||||||
|
New-PSItem South 12
|
||||||
|
|
||||||
|
New-PSItem NorthByNory 100
|
||||||
|
New-PSItem NothEast 110
|
||||||
|
New-PSItem Westerly 120
|
||||||
|
New-PSItem SouthWest 11
|
||||||
|
)
|
||||||
|
|
||||||
|
$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType DuplicateValues)
|
||||||
Reference in New Issue
Block a user