mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
added demo
This commit is contained in:
23
Examples/OutTabulator/demo.txt
Normal file
23
Examples/OutTabulator/demo.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
# ConvertFrom-Excel
|
||||
''
|
||||
|
||||
.\test.xlsx
|
||||
|
||||
Import-Excel .\test.xlsx | ft
|
||||
|
||||
ConvertFrom-Excel -ExcelFile .\test.xlsx -outFile .\targetout.html
|
||||
|
||||
# Create a column definition
|
||||
$columnOptions = @()
|
||||
|
||||
$columnOptions += New-ColumnOption -ColumnName Progress -formatter progress
|
||||
ConvertFrom-Excel -ExcelFile .\test.xlsx -outFile .\targetout.html -columnOptions $columnOptions
|
||||
|
||||
$columnOptions += New-ColumnOption Activity -formatter lineFormatter
|
||||
ConvertFrom-Excel -ExcelFile .\test.xlsx -outFile .\targetout.html -columnOptions $columnOptions
|
||||
|
||||
$columnOptions += New-ColumnOption -ColumnName Rating -formatter star
|
||||
$columnOptions += New-ColumnOption Driver -formatter tickCross
|
||||
ConvertFrom-Excel -ExcelFile .\test.xlsx -outFile .\targetout.html -columnOptions $columnOptions
|
||||
|
||||
ConvertFrom-Excel -ExcelFile .\test.xlsx -outFile .\targetout.html -columnOptions $columnOptions -groupBy Gender
|
||||
216
Examples/OutTabulator/start-demo.ps1
Normal file
216
Examples/OutTabulator/start-demo.ps1
Normal file
@@ -0,0 +1,216 @@
|
||||
## Start-Demo.ps1
|
||||
##################################################################################################
|
||||
## This is an overhaul of Jeffrey Snover's original Start-Demo script by Joel "Jaykul" Bennett
|
||||
##
|
||||
## I've switched it to using ReadKey instead of ReadLine (you don't have to hit Enter each time)
|
||||
## As a result, I've changed the names and keys for a lot of the operations, so that they make
|
||||
## sense with only a single letter to tell them apart (sorry if you had them memorized).
|
||||
##
|
||||
## I've also been adding features as I come across needs for them, and you'll contribute your
|
||||
## improvements back to the PowerShell Script repository as well.
|
||||
##################################################################################################
|
||||
## Revision History (version 3.3)
|
||||
## 3.3.3 Fixed: Script no longer says "unrecognized key" when you hit shift or ctrl, etc.
|
||||
## Fixed: Blank lines in script were showing as errors (now printed like comments)
|
||||
## 3.3.2 Fixed: Changed the "x" to match the "a" in the help text
|
||||
## 3.3.1 Fixed: Added a missing bracket in the script
|
||||
## 3.3 - Added: Added a "Clear Screen" option
|
||||
## - Added: Added a "Rewind" function (which I'm not using much)
|
||||
## 3.2 - Fixed: Put back the trap { continue; }
|
||||
## 3.1 - Fixed: No Output when invoking Get-Member (and other cmdlets like it???)
|
||||
## 3.0 - Fixed: Commands which set a variable, like: $files = ls
|
||||
## - Fixed: Default action doesn't continue
|
||||
## - Changed: Use ReadKey instead of ReadLine
|
||||
## - Changed: Modified the option prompts (sorry if you had them memorized)
|
||||
## - Changed: Various time and duration strings have better formatting
|
||||
## - Enhance: Colors are settable: prompt, command, comment
|
||||
## - Added: NoPauseAfterExecute switch removes the extra pause
|
||||
## If you set this, the next command will be displayed immediately
|
||||
## - Added: Auto Execute mode (FullAuto switch) runs the rest of the script
|
||||
## at an automatic speed set by the AutoSpeed parameter (or manually)
|
||||
## - Added: Automatically append an empty line to the end of the demo script
|
||||
## so you have a chance to "go back" after the last line of you demo
|
||||
##################################################################################################
|
||||
##
|
||||
param(
|
||||
$file=".\demo.txt",
|
||||
[int]$command=0,
|
||||
[System.ConsoleColor]$promptColor="Yellow",
|
||||
[System.ConsoleColor]$commandColor="White",
|
||||
[System.ConsoleColor]$commentColor="Green",
|
||||
[switch]$FullAuto,
|
||||
[int]$AutoSpeed = 3,
|
||||
[switch]$NoPauseAfterExecute
|
||||
)
|
||||
|
||||
$RawUI = $Host.UI.RawUI
|
||||
$hostWidth = $RawUI.BufferSize.Width
|
||||
|
||||
# A function for reading in a character
|
||||
function Read-Char() {
|
||||
$_OldColor = $RawUI.ForeGroundColor
|
||||
$RawUI.ForeGroundColor = "Red"
|
||||
$inChar=$RawUI.ReadKey("IncludeKeyUp")
|
||||
# loop until they press a character, so Shift or Ctrl, etc don't terminate us
|
||||
while($inChar.Character -eq 0){
|
||||
$inChar=$RawUI.ReadKey("IncludeKeyUp")
|
||||
}
|
||||
$RawUI.ForeGroundColor = $_OldColor
|
||||
return $inChar.Character
|
||||
}
|
||||
|
||||
function Rewind($lines, $index, $steps = 1) {
|
||||
$started = $index;
|
||||
$index -= $steps;
|
||||
while(($index -ge 0) -and ($lines[$index].Trim(" `t").StartsWith("#"))){
|
||||
$index--
|
||||
}
|
||||
if( $index -lt 0 ) { $index = $started }
|
||||
return $index
|
||||
}
|
||||
|
||||
$file = Resolve-Path $file
|
||||
while(-not(Test-Path $file)) {
|
||||
$file = Read-Host "Please enter the path of your demo script (Crtl+C to cancel)"
|
||||
$file = Resolve-Path $file
|
||||
}
|
||||
|
||||
Clear-Host
|
||||
|
||||
$_lines = Get-Content $file
|
||||
# Append an extra (do nothing) line on the end so we can still go back after the last line.
|
||||
$_lines += "Write-Host 'The End'"
|
||||
$_starttime = [DateTime]::now
|
||||
$FullAuto = $false
|
||||
|
||||
Write-Host -nonew -back black -fore $promptColor $(" " * $hostWidth)
|
||||
Write-Host -nonew -back black -fore $promptColor @"
|
||||
<Demo Started :: $(split-path $file -leaf)>$(' ' * ($hostWidth -(18 + $(split-path $file -leaf).Length)))
|
||||
"@
|
||||
Write-Host -nonew -back black -fore $promptColor "Press"
|
||||
Write-Host -nonew -back black -fore Red " ? "
|
||||
Write-Host -nonew -back black -fore $promptColor "for help.$(' ' * ($hostWidth -17))"
|
||||
Write-Host -nonew -back black -fore $promptColor $(" " * $hostWidth)
|
||||
|
||||
# We use a FOR and an INDEX ($_i) instead of a FOREACH because
|
||||
# it is possible to start at a different location and/or jump
|
||||
# around in the order.
|
||||
for ($_i = $Command; $_i -lt $_lines.count; $_i++)
|
||||
{
|
||||
# Put the current command in the Window Title along with the demo duration
|
||||
$Dur = [DateTime]::Now - $_StartTime
|
||||
$RawUI.WindowTitle = "$(if($dur.Hours -gt 0){'{0}h '})$(if($dur.Minutes -gt 0){'{1}m '}){2}s {3}" -f
|
||||
$dur.Hours, $dur.Minutes, $dur.Seconds, $($_Lines[$_i])
|
||||
|
||||
# Echo out the commmand to the console with a prompt as though it were real
|
||||
Write-Host -nonew -fore $promptColor "[$_i]$([char]0x2265) "
|
||||
if ($_lines[$_i].Trim(" ").StartsWith("#") -or $_lines[$_i].Trim(" ").Length -le 0) {
|
||||
Write-Host -fore $commentColor "$($_Lines[$_i]) "
|
||||
continue
|
||||
} else {
|
||||
Write-Host -nonew -fore $commandColor "$($_Lines[$_i]) "
|
||||
}
|
||||
|
||||
if( $FullAuto ) { Start-Sleep $autoSpeed; $ch = [char]13 } else { $ch = Read-Char }
|
||||
switch($ch)
|
||||
{
|
||||
"?" {
|
||||
Write-Host -Fore $promptColor @"
|
||||
|
||||
Running demo: $file
|
||||
(n) Next (p) Previous
|
||||
(q) Quit (s) Suspend
|
||||
(t) Timecheck (v) View $(split-path $file -leaf)
|
||||
(g) Go to line by number
|
||||
(f) Find lines by string
|
||||
(a) Auto Execute mode
|
||||
(c) Clear Screen
|
||||
"@
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"n" { # Next (do nothing)
|
||||
Write-Host -Fore $promptColor "<Skipping Line>"
|
||||
}
|
||||
"p" { # Previous
|
||||
Write-Host -Fore $promptColor "<Back one Line>"
|
||||
while ($_lines[--$_i].Trim(" ").StartsWith("#")){}
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"a" { # EXECUTE (Go Faster)
|
||||
$AutoSpeed = [int](Read-Host "Pause (seconds)")
|
||||
$FullAuto = $true;
|
||||
Write-Host -Fore $promptColor "<eXecute Remaining Lines>"
|
||||
$_i-- # Repeat this line, and then just blow through the rest
|
||||
}
|
||||
"q" { # Quit
|
||||
Write-Host -Fore $promptColor "<Quiting demo>"
|
||||
$_i = $_lines.count;
|
||||
break;
|
||||
}
|
||||
"v" { # View Source
|
||||
$lines[0..($_i-1)] | Write-Host -Fore Yellow
|
||||
$lines[$_i] | Write-Host -Fore Green
|
||||
$lines[($_i+1)..$lines.Count] | Write-Host -Fore Yellow
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"t" { # Time Check
|
||||
$dur = [DateTime]::Now - $_StartTime
|
||||
Write-Host -Fore $promptColor $(
|
||||
"{3} -- $(if($dur.Hours -gt 0){'{0}h '})$(if($dur.Minutes -gt 0){'{1}m '}){2}s" -f
|
||||
$dur.Hours, $dur.Minutes, $dur.Seconds, ([DateTime]::Now.ToShortTimeString()))
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"s" { # Suspend (Enter Nested Prompt)
|
||||
Write-Host -Fore $promptColor "<Suspending demo - type 'Exit' to resume>"
|
||||
$Host.EnterNestedPrompt()
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"g" { # GoTo Line Number
|
||||
$i = [int](Read-Host "line number")
|
||||
if($i -le $_lines.Count) {
|
||||
if($i -gt 0) {
|
||||
# extra line back because we're gonna step forward when we loop
|
||||
$_i = Rewind $_lines $_i (($_i-$i)+1)
|
||||
} else {
|
||||
$_i = -1 # Start negative, because we step forward when we loop
|
||||
}
|
||||
}
|
||||
}
|
||||
"f" { # Find by pattern
|
||||
$match = $_lines | Select-String (Read-Host "search string")
|
||||
if($match -eq $null) {
|
||||
Write-Host -Fore Red "Can't find a matching line"
|
||||
} else {
|
||||
$match | % { Write-Host -Fore $promptColor $("[{0,2}] {1}" -f ($_.LineNumber - 1), $_.Line) }
|
||||
if($match.Count -lt 1) {
|
||||
$_i = $match.lineNumber - 2 # back a line, we're gonna step forward when we loop
|
||||
} else {
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
}
|
||||
}
|
||||
"c" {
|
||||
Clear-Host
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
"$([char]13)" { # on enter
|
||||
Write-Host
|
||||
trap [System.Exception] {Write-Error $_; continue;}
|
||||
Invoke-Expression ($_lines[$_i]) | out-default
|
||||
if(-not $NoPauseAfterExecute -and -not $FullAuto) {
|
||||
$null = $RawUI.ReadKey("NoEcho,IncludeKeyUp") # Pause after output for no apparent reason... ;)
|
||||
}
|
||||
}
|
||||
default
|
||||
{
|
||||
Write-Host -Fore Green "`nKey not recognized. Press ? for help, or ENTER to execute the command."
|
||||
$_i-- # back a line, we're gonna step forward when we loop
|
||||
}
|
||||
}
|
||||
}
|
||||
$dur = [DateTime]::Now - $_StartTime
|
||||
Write-Host -Fore $promptColor $(
|
||||
"<Demo Complete -- $(if($dur.Hours -gt 0){'{0}h '})$(if($dur.Minutes -gt 0){'{1}m '}){2}s>" -f
|
||||
$dur.Hours, $dur.Minutes, $dur.Seconds, [DateTime]::Now.ToLongTimeString())
|
||||
Write-Host -Fore $promptColor $([DateTime]::now)
|
||||
Write-Host
|
||||
80
Examples/OutTabulator/targetout.html
Normal file
80
Examples/OutTabulator/targetout.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Out-TabulatorView</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript" src="file:///C:\Program Files\WindowsPowerShell\Modules\OutTabulatorView\js\jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript" src="file:///C:\Program Files\WindowsPowerShell\Modules\OutTabulatorView\js\jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="file:///C:\Program Files\WindowsPowerShell\Modules\OutTabulatorView\js\tabulator.min.js"></script>
|
||||
<script type="text/javascript" src="file:///C:\Program Files\WindowsPowerShell\Modules\OutTabulatorView\js\jquery.sparkline.min.js"></script>
|
||||
|
||||
<link href="file:///C:\Program Files\WindowsPowerShell\Modules\OutTabulatorView\css\tabulator.min.css" rel="stylesheet">
|
||||
|
||||
|
||||
<div id="example-table"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var lineFormatter = function(cell, formatterParams){
|
||||
setTimeout(function(){ //give cell enough time to be added to the DOM before calling sparkline formatter
|
||||
cell.getElement().sparkline(cell.getValue(), {width:"100%", type:"line", disableTooltips:true});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
var tabledata = [{"Name":"Alan Francis","Progress":90,"Activity":[4,17,11,7,6,12,14,13,11,10,9,6,11,12,0,5,12,14,18,11],"Gender":"male","Rating":3,"Color":"blue","dob":"07/08/1972","Driver":"true"},{"Name":"Brendon Philips","Progress":100,"Activity":[3,7,9,1,4,8,2,6,4,2,1,3,1,3,3,1,1,3,1,3],"Gender":"male","Rating":1,"Color":"orange","dob":"01/08/1980","Driver":""},{"Name":"Christine Lobowski","Progress":42,"Activity":[1,2,5,4,1,16,4,2,1,3,3,7,9,1,4,8,2,6,4,2],"Gender":"female","Rating":0,"Color":"green","dob":"22/05/1982","Driver":"true"},{"Name":"Ed White","Progress":70,"Activity":[20,17,15,11,16,9,4,17,11,12,0,5,12,14,18,11,12,14,20,12],"Gender":"male","Rating":0,"Color":"yellow","dob":"19/06/1976","Driver":""},{"Name":"Emily Sykes","Progress":42,"Activity":[11,15,19,20,17,16,16,5,3,2,1,2,3,4,5,4,2,5,9,8],"Gender":"female","Rating":1,"Color":"maroon","dob":"11/11/1970","Driver":""},{"Name":"Emma Netwon","Progress":40,"Activity":[3,7,9,1,4,8,3,7,9,1,4,8,2,6,4,2,2,6,4,2],"Gender":"female","Rating":4,"Color":"brown","dob":"07/10/1963","Driver":"true"},{"Name":"Frank Harbours","Progress":38,"Activity":[20,17,15,11,16,9,12,14,20,12,11,7,6,12,14,13,11,10,9,6],"Gender":"male","Rating":4,"Color":"red","dob":"12/05/1966","Driver":1},{"Name":"Gemma Jane","Progress":60,"Activity":[4,17,11,12,0,5,12,14,18,11,11,15,19,20,17,16,16,5,3,2],"Gender":"female","Rating":0,"Color":"red","dob":"22/05/1982","Driver":"true"},{"Name":"Hannah Farnsworth","Progress":30,"Activity":[1,2,5,4,1,16,10,12,14,16,13,9,7,11,10,13,4,2,1,3],"Gender":"female","Rating":1,"Color":"pink","dob":"11/02/1991","Driver":""},{"Name":"James Newman","Progress":73,"Activity":[1,20,5,3,10,13,17,15,9,11,1,2,3,4,5,4,2,5,9,8],"Gender":"male","Rating":5,"Color":"red","dob":"22/03/1998","Driver":""},{"Name":"Jamie Newhart","Progress":23,"Activity":[11,7,6,12,14,13,11,10,9,6,4,17,11,12,0,5,12,14,18,11],"Gender":"male","Rating":3,"Color":"green","dob":"14/05/1985","Driver":"true"},{"Name":"Jenny Green","Progress":56,"Activity":[11,15,19,20,17,15,11,16,9,12,14,20,12,20,17,16,16,5,3,2],"Gender":"female","Rating":4,"Color":"indigo","dob":"12/11/1998","Driver":"true"},{"Name":"John Phillips","Progress":80,"Activity":[11,7,6,12,14,1,20,5,3,10,13,17,15,9,1,13,11,10,9,6],"Gender":"male","Rating":1,"Color":"green","dob":"24/09/1950","Driver":"true"},{"Name":"Margret Marmajuke","Progress":16,"Activity":[1,3,1,3,3,1,1,3,1,3,20,17,15,11,16,9,12,14,20,12],"Gender":"female","Rating":5,"Color":"yellow","dob":"31/01/1999","Driver":""},{"Name":"Martin Barryman","Progress":20,"Activity":[1,2,3,4,5,4,11,7,6,12,14,13,11,10,9,6,2,5,9,8],"Gender":"male","Rating":5,"Color":"violet","dob":"04/04/2001","Driver":""},{"Name":"Mary May","Progress":1,"Activity":[10,12,14,16,13,9,7,11,10,13,1,2,5,4,1,16,4,2,1,3],"Gender":"female","Rating":2,"Color":"blue","dob":"14/05/1982","Driver":"true"},{"Name":"Oli Bob","Progress":12,"Activity":[1,20,5,3,10,13,17,15,9,11,10,12,14,16,13,9,7,11,10,13],"Gender":"male","Rating":1,"Color":"red","dob":"19/02/1984","Driver":1},{"Name":"Paul Branderson","Progress":60,"Activity":[1,3,1,3,3,1,11,15,19,20,17,16,16,5,3,2,1,3,1,3],"Gender":"male","Rating":5,"Color":"orange","dob":"01/01/1982","Driver":""},{"Name":"Victoria Bath","Progress":20,"Activity":[10,12,14,16,13,9,7,1,2,3,4,5,4,2,5,9,8,11,10,13],"Gender":"female","Rating":2,"Color":"purple","dob":"22/03/1986","Driver":null}]
|
||||
|
||||
$("#example-table").tabulator(
|
||||
{
|
||||
"outFile": ".\\targetout.html",
|
||||
"columns": [
|
||||
{
|
||||
"field": "Name",
|
||||
"title": "Name"
|
||||
},
|
||||
{
|
||||
"field": "Progress",
|
||||
"title": "Progress",
|
||||
"formatter": "progress"
|
||||
},
|
||||
{
|
||||
"field": "Activity",
|
||||
"title": "Activity",
|
||||
"formatter": lineFormatter
|
||||
},
|
||||
{
|
||||
"field": "Gender",
|
||||
"title": "Gender"
|
||||
},
|
||||
{
|
||||
"field": "Rating",
|
||||
"title": "Rating",
|
||||
"formatter": "star"
|
||||
},
|
||||
{
|
||||
"field": "Color",
|
||||
"title": "Color"
|
||||
},
|
||||
{
|
||||
"field": "dob",
|
||||
"title": "dob"
|
||||
},
|
||||
{
|
||||
"field": "Driver",
|
||||
"title": "Driver",
|
||||
"formatter": "tickCross"
|
||||
}
|
||||
],
|
||||
"groupBy": "Gender"
|
||||
|
||||
});
|
||||
|
||||
$("#example-table").tabulator("setData", tabledata);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
9
Examples/OutTabulator/tryConvertFromExcel.ps1
Normal file
9
Examples/OutTabulator/tryConvertFromExcel.ps1
Normal file
@@ -0,0 +1,9 @@
|
||||
[CmdletBinding()]
|
||||
param($outFile = "$PSScriptRoot\targetout.html")
|
||||
|
||||
$columnOptions = @()
|
||||
|
||||
$columnOptions += New-ColumnOption -ColumnName Progress -formatter progress
|
||||
$columnOptions += New-ColumnOption -ColumnName Activity -formatter lineFormatter
|
||||
|
||||
ConvertFrom-Excel -ExcelFile $PSScriptRoot\test.xlsx -outFile $PSScriptRoot\targetout.html -columnOptions $columnOptions
|
||||
Reference in New Issue
Block a user