mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added try/catch. Expanded aliases
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
ConvertFrom-ExcelToSQLInsert People .\testSQLGen.xlsx
|
ConvertFrom-ExcelToSQLInsert People .\testSQLGen.xlsx
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Import-Module ..\..\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$f = ".\dashboard.xlsx"
|
$f = ".\dashboard.xlsx"
|
||||||
Remove-Item $f -ErrorAction Ignore
|
Remove-Item $f -ErrorAction Ignore
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,4 @@
|
|||||||
Import-Module ..\..\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
|
||||||
ConvertFrom-ExcelToSQLInsert -TableName "Movies" -Path ".\Movies.xlsx" -ConvertEmptyStringsToNull
|
ConvertFrom-ExcelToSQLInsert -TableName "Movies" -Path ".\Movies.xlsx" -ConvertEmptyStringsToNull
|
||||||
''
|
''
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
param ($fibonacciDigits=10)
|
param ($fibonacciDigits=10)
|
||||||
|
|
||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "fib.xlsx"
|
$file = "fib.xlsx"
|
||||||
rm "fib.xlsx" -ErrorAction Ignore
|
Remove-Item "fib.xlsx" -ErrorAction Ignore
|
||||||
|
|
||||||
$(
|
$(
|
||||||
New-PSItem 0
|
New-PSItem 0
|
||||||
New-PSItem 1
|
New-PSItem 1
|
||||||
|
|
||||||
(
|
(
|
||||||
2..$fibonacciDigits |
|
2..$fibonacciDigits |
|
||||||
ForEach {
|
ForEach-Object {
|
||||||
New-PSItem ('=a{0}+a{1}' -f ($_+1),$_)
|
New-PSItem ('=a{0}+a{1}' -f ($_+1),$_)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Binary file not shown.
@@ -1,12 +1,16 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
$xlfile = "$env:temp\testFmt.xlsx"
|
||||||
|
|
||||||
Get-Process |
|
Get-Process |
|
||||||
Select-Object Company,Handles,PM, NPM|
|
Select-Object Company,Handles,PM, NPM|
|
||||||
Export-Excel $xlfile -Show -AutoSize -CellStyleSB {
|
Export-Excel $xlfile -Show -AutoSize -CellStyleSB {
|
||||||
param(
|
param(
|
||||||
$workSheet,
|
$workSheet,
|
||||||
$totalRows,
|
$totalRows,
|
||||||
$lastColumn
|
$lastColumn
|
||||||
)
|
)
|
||||||
|
|
||||||
Set-CellStyle $workSheet 1 $LastColumn Solid Cyan
|
Set-CellStyle $workSheet 1 $LastColumn Solid Cyan
|
||||||
|
|
||||||
foreach($row in (2..$totalRows | Where-Object {$_ % 2 -eq 0})) {
|
foreach($row in (2..$totalRows | Where-Object {$_ % 2 -eq 0})) {
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
$xlfile = "$env:temp\testFmt.xlsx"
|
||||||
|
Remove-Item $xlfile -ErrorAction Ignore
|
||||||
|
|
||||||
$RandomStyle = {
|
$RandomStyle = {
|
||||||
param(
|
param(
|
||||||
$workSheet,
|
$workSheet,
|
||||||
$totalRows,
|
$totalRows,
|
||||||
$lastColumn
|
$lastColumn
|
||||||
)
|
)
|
||||||
|
|
||||||
2..$totalRows | ForEach-Object{
|
2..$totalRows | ForEach-Object{
|
||||||
Set-CellStyle $workSheet $_ $LastColumn Solid (Write-Output LightGreen Gray Red|Get-Random)
|
Set-CellStyle $workSheet $_ $LastColumn Solid (Write-Output LightGreen Gray Red|Get-Random)
|
||||||
@@ -11,5 +16,5 @@ $RandomStyle = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Get-Process |
|
Get-Process |
|
||||||
Select-Object Company,Handles,PM, NPM|
|
Select-Object Company,Handles,PM, NPM|
|
||||||
Export-Excel $xlfile -Show -AutoSize -CellStyleSB $RandomStyle
|
Export-Excel $xlfile -Show -AutoSize -CellStyleSB $RandomStyle
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
|
||||||
Import-Html "http://en.wikipedia.org/wiki/Demographics_of_India" 4
|
Import-Html "http://en.wikipedia.org/wiki/Demographics_of_India" 4
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
Import-Html "http://www.science.co.il/PTelements.asp" 1
|
Import-Html "http://www.science.co.il/PTelements.asp" 1
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
Import-Html "https://en.wikipedia.org/wiki/List_of_Star_Trek:_The_Original_Series_episodes" 2
|
Import-Html "https://en.wikipedia.org/wiki/List_of_Star_Trek:_The_Original_Series_episodes" 2
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
ColumnChart -Title "Central Limit Theorem" -NoLegend ($(
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
ColumnChart -Title "Central Limit Theorem" -NoLegend ($(
|
||||||
for ($i = 1; $i -le 500; $i++) {
|
for ($i = 1; $i -le 500; $i++) {
|
||||||
$s = 0
|
$s = 0
|
||||||
for ($j = 1; $j -le 100; $j++) {
|
for ($j = 1; $j -le 100; $j++) {
|
||||||
|
|||||||
@@ -2,5 +2,7 @@
|
|||||||
# Sum up handles by company
|
# Sum up handles by company
|
||||||
# Show the Pie Chart
|
# Show the Pie Chart
|
||||||
|
|
||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
PieChart -Title "Total Handles by Company" `
|
PieChart -Title "Total Handles by Company" `
|
||||||
(Invoke-Sum (Get-Process|Where company) company handles)
|
(Invoke-Sum (Get-Process | Where-Object company) company handles)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
# Sum up PM by company
|
# Sum up PM by company
|
||||||
# Show the Pie Chart
|
# Show the Pie Chart
|
||||||
|
|
||||||
PieChart -Title "Total PM by Company" `
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
(Invoke-Sum (Get-Process|Where company) company pm)
|
|
||||||
|
PieChart -Title "Total PM by Company" `
|
||||||
|
(Invoke-Sum (Get-Process|Where-Object company) company pm)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
BarChart (.\TargetData.ps1) "A BarChart"
|
BarChart (.\TargetData.ps1) "A BarChart"
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
ColumnChart (.\TargetData.ps1) "A ColumnChart"
|
ColumnChart (.\TargetData.ps1) "A ColumnChart"
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
PieChart (.\TargetData.ps1) "A PieChart"
|
PieChart (.\TargetData.ps1) "A PieChart"
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$header = echo `
|
$header = echo `
|
||||||
'Date/Time - Peak Brightness (UT)' `
|
'Date/Time - Peak Brightness (UT)' `
|
||||||
'Latitude (Deg)' `
|
'Latitude (Deg)' `
|
||||||
@@ -12,8 +14,8 @@ $header = echo `
|
|||||||
|
|
||||||
$splat=@{
|
$splat=@{
|
||||||
url='http://neo.jpl.nasa.gov/fireballs/'
|
url='http://neo.jpl.nasa.gov/fireballs/'
|
||||||
index=5
|
index=5
|
||||||
Header=$header
|
Header=$header
|
||||||
FirstDataRow=1
|
FirstDataRow=1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$data = $(
|
$data = $(
|
||||||
New-PSItem 100 -100
|
New-PSItem 100 -100
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$data = $(
|
$data = $(
|
||||||
New-PSItem 100 -100
|
New-PSItem 100 -100
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$data = $(
|
$data = $(
|
||||||
New-PSItem 1
|
New-PSItem 1
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$data = $(
|
$data = $(
|
||||||
New-PSItem 100 -100
|
New-PSItem 100 -100
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
||||||
Select DeviceID,Volumename,Size,Freespace |
|
Select-Object DeviceID,Volumename,Size,Freespace |
|
||||||
Export-Excel -Path $file -Show -AutoSize -NumberFormat "0"
|
Export-Excel -Path $file -Show -AutoSize -NumberFormat "0"
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "disks.xlsx"
|
$file = "disks.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
||||||
Select DeviceID,Volumename,Size,Freespace |
|
Select-Object DeviceID,Volumename,Size,Freespace |
|
||||||
Export-Excel -Path $file -Show -AutoSize
|
Export-Excel -Path $file -Show -AutoSize
|
||||||
BIN
Examples/NumberFormat/disks.xlsx
Normal file
BIN
Examples/NumberFormat/disks.xlsx
Normal file
Binary file not shown.
@@ -1,6 +1,8 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$file = "sales.xlsx"
|
$file = "sales.xlsx"
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$xlPkg = Import-Csv .\sales.csv | Export-Excel $file -PassThru
|
$xlPkg = Import-Csv .\sales.csv | Export-Excel $file -PassThru
|
||||||
|
|
||||||
@@ -9,8 +11,8 @@ $ws = $xlPkg.Workbook.WorkSheets[1]
|
|||||||
$ws.Cells["E1"].Value = "TotalSold"
|
$ws.Cells["E1"].Value = "TotalSold"
|
||||||
$ws.Cells["F1"].Value = "Add 10%"
|
$ws.Cells["F1"].Value = "Add 10%"
|
||||||
|
|
||||||
2..($ws.Dimension.Rows) |
|
2..($ws.Dimension.Rows) |
|
||||||
ForEach {
|
ForEach-Object {
|
||||||
$ws.Cells["E$_"].Formula = "=C$_+D$_"
|
$ws.Cells["E$_"].Formula = "=C$_+D$_"
|
||||||
$ws.Cells["F$_"].Formula = "=E$_+(10%*(C$_+D$_))"
|
$ws.Cells["F$_"].Formula = "=E$_+(10%*(C$_+D$_))"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Examples/PassThru/sales.xlsx
Normal file
BIN
Examples/PassThru/sales.xlsx
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
Import-Module ..\..\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
Remove-Item .\test1.xlsx -ErrorAction Ignore
|
Remove-Item .\test1.xlsx -ErrorAction Ignore
|
||||||
|
|
||||||
|
|||||||
BIN
Examples/PivotTable/test1.xlsx
Normal file
BIN
Examples/PivotTable/test1.xlsx
Normal file
Binary file not shown.
BIN
Examples/PivotTableFilters/testPivot.xlsx
Normal file
BIN
Examples/PivotTableFilters/testPivot.xlsx
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
Import-Module ..\..\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$xlFile=".\testPivot.xlsx"
|
$xlFile=".\testPivot.xlsx"
|
||||||
Remove-Item $xlFile -ErrorAction Ignore
|
Remove-Item $xlFile -ErrorAction Ignore
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$plt = New-Plot
|
$plt = New-Plot
|
||||||
$plt.Plot((Get-Range 0 5 .02|%{[math]::Cos(2*[math]::pi*$_)}))
|
$plt.Plot((Get-Range 0 5 .02|%{[math]::Cos(2*[math]::pi*$_)}))
|
||||||
$plt.SetChartSize(800,300)
|
$plt.SetChartSize(800,300)
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
Import-Module -name ImportExcel -Force -Verbose
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
$sql = @"
|
$sql = @"
|
||||||
SELECT rootfile.baseName , rootfile.extension , Image.fileWidth AS width , image.fileHeight AS height ,
|
SELECT rootfile.baseName , rootfile.extension , Image.fileWidth AS width , image.fileHeight AS height ,
|
||||||
metadata.dateDay , metadata.dateMonth , metadata.dateYear , Image.captureTime AS dateTaken,
|
metadata.dateDay , metadata.dateMonth , metadata.dateYear , Image.captureTime AS dateTaken,
|
||||||
metadata.hasGPS , metadata.GPSLatitude , metadata.GPSLongitude ,
|
metadata.hasGPS , metadata.GPSLatitude , metadata.GPSLongitude ,
|
||||||
metadata.focalLength , metadata.flashFired , metadata.ISOSpeedRating AS ISOSpeed,
|
metadata.focalLength , metadata.flashFired , metadata.ISOSpeedRating AS ISOSpeed,
|
||||||
metadata.Aperture AS apertureValue , metadata.ShutterSpeed AS shutterSpeedValue,
|
metadata.Aperture AS apertureValue , metadata.ShutterSpeed AS shutterSpeedValue,
|
||||||
Image.bitdepth , image.colorLabels ,
|
Image.bitdepth , image.colorLabels ,
|
||||||
Camera.Value AS cameraModel , LensRef.value AS lensModel
|
Camera.Value AS cameraModel , LensRef.value AS lensModel
|
||||||
FROM Adobe_images image
|
FROM Adobe_images image
|
||||||
JOIN AgLibraryFile rootFile ON rootfile.id_local = image.rootFile
|
JOIN AgLibraryFile rootFile ON rootfile.id_local = image.rootFile
|
||||||
JOIN AgharvestedExifMetadata metadata ON image.id_local = metadata.image
|
JOIN AgharvestedExifMetadata metadata ON image.id_local = metadata.image
|
||||||
LEFT JOIN AgInternedExifLens LensRef ON LensRef.id_Local = metadata.lensRef
|
LEFT JOIN AgInternedExifLens LensRef ON LensRef.id_Local = metadata.lensRef
|
||||||
LEFT JOIN AgInternedExifCameraModel Camera ON Camera.id_local = metadata.cameraModelRef
|
LEFT JOIN AgInternedExifCameraModel Camera ON Camera.id_local = metadata.cameraModelRef
|
||||||
"@
|
"@
|
||||||
``
|
|
||||||
#Sql Statement gets 20 columns of data from Adobe lightroom database
|
|
||||||
#Define a pivot table and chart for total pictures with each lens.
|
|
||||||
|
|
||||||
$pt = @{"LensPivot" = @{ "PivotTableName" = "LensPivot";
|
#Sql Statement gets 20 columns of data from Adobe lightroom database
|
||||||
|
#Define a pivot table and chart for total pictures with each lens.
|
||||||
|
|
||||||
|
$pt = @{"LensPivot" = @{ "PivotTableName" = "LensPivot";
|
||||||
"SourceWorkSheet" = "Sheet1" ;
|
"SourceWorkSheet" = "Sheet1" ;
|
||||||
"PivotRows" = "LensModel" ;
|
"PivotRows" = "LensModel" ;
|
||||||
"PivotData" = @{"basename" = "Count"} ;
|
"PivotData" = @{"basename" = "Count"} ;
|
||||||
"IncludePivotChart" = $true ;
|
"IncludePivotChart" = $true ;
|
||||||
"NoLegend" = $true ;
|
"NoLegend" = $true ;
|
||||||
"ShowPercent" = $true ;
|
"ShowPercent" = $true ;
|
||||||
"ChartType" = "Pie" ;
|
"ChartType" = "Pie" ;
|
||||||
"ChartTitle" = "Split by Lens" }
|
"ChartTitle" = "Split by Lens" }
|
||||||
}
|
}
|
||||||
|
|
||||||
#we want to add 3 columns, translate Apperture value and Shutter speed value into familar f/ and seconds notation, and use these and ISO to calculate EV level
|
#we want to add 3 columns, translate Apperture value and Shutter speed value into familar f/ and seconds notation, and use these and ISO to calculate EV level
|
||||||
$Avalue = {"=IF(P$ROW>6.63,TEXT(ROUND(Sqrt(Power(2,O$ROW)),1),`"`"`"f/`"`"0.0`")," +
|
$Avalue = {"=IF(P$ROW>6.63,TEXT(ROUND(Sqrt(Power(2,O$ROW)),1),`"`"`"f/`"`"0.0`")," +
|
||||||
@@ -37,52 +37,52 @@ $Svalue = {"=IF(P$ROW>2,TEXT(ROUND(POWER(2,P$ROW),0),`"`"`"1/`"`"0`"`"sec
|
|||||||
"TEXT(ROUND(1/POWER(2,P$ROW),2),`"0`"`"Sec`"`"`")))"}
|
"TEXT(ROUND(1/POWER(2,P$ROW),2),`"0`"`"Sec`"`"`")))"}
|
||||||
$evValue = {"=ROUND(P$Row+O$Row-(LOG(N$Row/100,2)),0)" }
|
$evValue = {"=ROUND(P$Row+O$Row-(LOG(N$Row/100,2)),0)" }
|
||||||
|
|
||||||
#remove and recreate the file
|
#remove and recreate the file
|
||||||
Remove-Item -Path "~\Documents\temp.xlsx" -ErrorAction SilentlyContinue
|
Remove-Item -Path "~\Documents\temp.xlsx" -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
#Open a connection to the ODBC source "LR" (which points to the SQLLite DB for Lightroom), run the SQL query, and drop into Excel - in sheet1, autosizing columns.
|
#Open a connection to the ODBC source "LR" (which points to the SQLLite DB for Lightroom), run the SQL query, and drop into Excel - in sheet1, autosizing columns.
|
||||||
$e = Send-SQLDataToExcel -Path "~\Documents\temp.xlsx" -WorkSheetname "Sheet1" -Connection "DSN=LR" -SQL $sql -AutoSize -Passthru
|
$e = Send-SQLDataToExcel -Path "~\Documents\temp.xlsx" -WorkSheetname "Sheet1" -Connection "DSN=LR" -SQL $sql -AutoSize -Passthru
|
||||||
|
|
||||||
#Add columns, then format them and hide the ones which aren't of interest.
|
#Add columns, then format them and hide the ones which aren't of interest.
|
||||||
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 21 -Value $Avalue -Heading "Apperture"
|
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 21 -Value $Avalue -Heading "Apperture"
|
||||||
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 22 -Value $Svalue -Heading "Shutter"
|
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 22 -Value $Svalue -Heading "Shutter"
|
||||||
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 23 -Value $Evvalue -Heading "Ev"
|
Set-Column -Worksheet $e.workbook.Worksheets["sheet1"] -Column 23 -Value $Evvalue -Heading "Ev"
|
||||||
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column(21) -HorizontalAlignment Left -AutoFit
|
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column(21) -HorizontalAlignment Left -AutoFit
|
||||||
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column(22) -HorizontalAlignment Right -AutoFit
|
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column(22) -HorizontalAlignment Right -AutoFit
|
||||||
@(5,6,7,13,15,16,17,18) | ForEach-Object {
|
@(5,6,7,13,15,16,17,18) | ForEach-Object {
|
||||||
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column($_) -Hidden
|
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Column($_) -Hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
#Center the column labels.
|
#Center the column labels.
|
||||||
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Row(1) -HorizontalAlignment Center
|
Set-Format -Address $e.workbook.Worksheets["sheet1" ].Row(1) -HorizontalAlignment Center
|
||||||
|
|
||||||
#Format the data as a nice Table, Create the pivot table & chart defined above, show the file in Excel in excel after saving.
|
#Format the data as a nice Table, Create the pivot table & chart defined above, show the file in Excel in excel after saving.
|
||||||
Export-Excel -ExcelPackage $e -WorkSheetname "sheet1" -TableName "Table" -PivotTableDefinition $pt -Show
|
Export-Excel -ExcelPackage $e -WorkSheetname "sheet1" -TableName "Table" -PivotTableDefinition $pt -Show
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Remove-Item .\demo3.xlsx
|
Remove-Item .\demo3.xlsx
|
||||||
#Database query to get race wins, Poles and fastest lapes for the 25 best drivers; we already have a connection to the DB in $dbSessions
|
#Database query to get race wins, Poles and fastest lapes for the 25 best drivers; we already have a connection to the DB in $dbSessions
|
||||||
$session = $DbSessions["f1"]
|
$session = $DbSessions["f1"]
|
||||||
$SQL = @"
|
$SQL = @"
|
||||||
SELECT TOP 25 DriverName,
|
SELECT TOP 25 DriverName,
|
||||||
Count(RaceDate) AS Races,
|
Count(RaceDate) AS Races,
|
||||||
Count(Win) AS Wins,
|
Count(Win) AS Wins,
|
||||||
Count(Pole) AS Poles,
|
Count(Pole) AS Poles,
|
||||||
Count(FastestLap) AS Fastlaps
|
Count(FastestLap) AS Fastlaps
|
||||||
FROM Results
|
FROM Results
|
||||||
GROUP BY DriverName
|
GROUP BY DriverName
|
||||||
ORDER BY (Count(win)) DESC
|
ORDER BY (Count(win)) DESC
|
||||||
"@
|
"@
|
||||||
|
|
||||||
#Run the query and put the results in workshet "Winners", autosize the columns and hold on to the ExcelPackage object
|
#Run the query and put the results in workshet "Winners", autosize the columns and hold on to the ExcelPackage object
|
||||||
$Excel = Send-SQLDataToExcel -SQL $sql -Session $session -path .\demo3.xlsx -WorkSheetname "Winners" -AutoSize -Passthru
|
$Excel = Send-SQLDataToExcel -SQL $sql -Session $session -path .\demo3.xlsx -WorkSheetname "Winners" -AutoSize -Passthru
|
||||||
#Create and format columns for the ratio of Wins to poles and fast laps.
|
#Create and format columns for the ratio of Wins to poles and fast laps.
|
||||||
Set-Column -ExcelPackage $Excel -WorkSheetname "Winners" -column 6 -Heading "WinsToPoles" -Value {"=D$row/C$row"}
|
Set-Column -ExcelPackage $Excel -WorkSheetname "Winners" -column 6 -Heading "WinsToPoles" -Value {"=D$row/C$row"}
|
||||||
Set-Column -ExcelPackage $Excel -WorkSheetname "Winners" -column 7 -Heading "WinsToFast" -Value {"=E$row/C$row"}
|
Set-Column -ExcelPackage $Excel -WorkSheetname "Winners" -column 7 -Heading "WinsToFast" -Value {"=E$row/C$row"}
|
||||||
6..7 | ForEach-Object {
|
6..7 | ForEach-Object {
|
||||||
Set-Format -Address $Excel.Workbook.Worksheets["Winners"].column($_) -NumberFormat "0.0%" -AutoFit }
|
Set-Format -Address $Excel.Workbook.Worksheets["Winners"].column($_) -NumberFormat "0.0%" -AutoFit }
|
||||||
#Define a chart to show the relationship of lest on an XY Grid, create the ranges required in the, add the chart and show the file in Excel in excel after saving.
|
#Define a chart to show the relationship of lest on an XY Grid, create the ranges required in the, add the chart and show the file in Excel in excel after saving.
|
||||||
$chart = New-ExcelChart -NoLegend -ChartType XYScatter -XRange WinsToFast -YRange WinsToPoles -ShowCategory -Column 7 -Width 2000 -Height 700
|
$chart = New-ExcelChart -NoLegend -ChartType XYScatter -XRange WinsToFast -YRange WinsToPoles -ShowCategory -Column 7 -Width 2000 -Height 700
|
||||||
Export-Excel -ExcelPackage $Excel -WorkSheetname "Winners" -AutoNameRange -ExcelChartDefinition $chart -Show
|
Export-Excel -ExcelPackage $Excel -WorkSheetname "Winners" -AutoNameRange -ExcelChartDefinition $chart -Show
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
ipmo C:\Users\mcp\Documents\GitHub\ImportExcel\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
Get-SQL -Session f1 -Excel -Connection C:\Users\mcp\OneDrive\Public\F1\f1Results.xlsx -showtables -Verbose
|
Get-SQL -Session f1 -Excel -Connection C:\Users\mcp\OneDrive\Public\F1\f1Results.xlsx -showtables -Verbose
|
||||||
|
|
||||||
del .\demo3.xlsx
|
Remove-Item .\demo3.xlsx
|
||||||
$session = $DbSessions["f1"]
|
$session = $DbSessions["f1"]
|
||||||
|
|
||||||
$SQL = "SELECT top 25 DriverName, Count(RaceDate) as Races ,
|
$SQL = "SELECT top 25 DriverName, Count(RaceDate) as Races ,
|
||||||
Count(Win) as Wins, Count(Pole) as Poles, Count(FastestLap) as Fastlaps
|
Count(Win) as Wins, Count(Pole) as Poles, Count(FastestLap) as Fastlaps
|
||||||
FROM Results GROUP BY DriverName
|
FROM Results GROUP BY DriverName
|
||||||
order by (count(win)) desc"
|
order by (count(win)) desc"
|
||||||
$Excel = Send-SQLDataToExcel -SQL $sql -Session $session -path .\demo3.xlsx -WorkSheetname "Winners" -AutoSize -AutoNameRange -BoldTopRow -FreezeTopRow -Passthru
|
$Excel = Send-SQLDataToExcel -SQL $sql -Session $session -path .\demo3.xlsx -WorkSheetname "Winners" -AutoSize -AutoNameRange -BoldTopRow -FreezeTopRow -Passthru
|
||||||
|
|
||||||
$ws = $Excel.Workbook.Worksheets["Winners"]
|
$ws = $Excel.Workbook.Worksheets["Winners"]
|
||||||
|
|
||||||
Set-Row -Worksheet $ws -Heading "Average" -Value {"=Average($columnName`2:$columnName$endrow)"} -NumberFormat "0.0" -Bold
|
Set-Row -Worksheet $ws -Heading "Average" -Value {"=Average($columnName`2:$columnName$endrow)"} -NumberFormat "0.0" -Bold
|
||||||
Set-Column -Worksheet $ws -Heading "WinsToPoles" -Value {"=D$row/C$row"} -Column 6 -AutoSize -AutoNameRange
|
Set-Column -Worksheet $ws -Heading "WinsToPoles" -Value {"=D$row/C$row"} -Column 6 -AutoSize -AutoNameRange
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
$p = ps | select Company, Handles | Export-Excel c:\temp\testBackgroundColor.xlsx -ClearSheet -KillExcel -PassThru
|
|
||||||
|
$p = Get-Process | Select-Object Company, Handles | Export-Excel c:\temp\testBackgroundColor.xlsx -ClearSheet -KillExcel -PassThru
|
||||||
|
|
||||||
$ws = $p.Workbook.WorkSheets[1]
|
$ws = $p.Workbook.WorkSheets[1]
|
||||||
$totalRows = $ws.Dimension.Rows
|
$totalRows = $ws.Dimension.Rows
|
||||||
|
|
||||||
Set-Format -Address $ws.Cells["B2:B$($totalRows)"] -BackgroundColor LightBlue
|
Set-Format -Address $ws.Cells["B2:B$($totalRows)"] -BackgroundColor LightBlue
|
||||||
|
|
||||||
Export-Excel -ExcelPackage $p -show
|
Export-Excel -ExcelPackage $p -show -AutoSize
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
. ..\New-PSItem.ps1
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
rm *.xlsx
|
|
||||||
|
#. ..\New-PSItem.ps1
|
||||||
|
|
||||||
|
Remove-Item *.xlsx
|
||||||
|
|
||||||
$(
|
$(
|
||||||
New-PSItem 12001 Nails 37 3.99 =C2*D2 (echo ID Product Quantity Price Total)
|
New-PSItem 12001 Nails 37 3.99 =C2*D2 (echo ID Product Quantity Price Total)
|
||||||
New-PSItem 12002 Hammer 5 12.10 =C3*D3
|
New-PSItem 12002 Hammer 5 12.10 =C3*D3
|
||||||
New-PSItem 12003 Saw 12 15.37 =C4*D4
|
New-PSItem 12003 Saw 12 15.37 =C4*D4
|
||||||
New-PSItem 12010 Drill 20 8 =C5*D5
|
New-PSItem 12010 Drill 20 8 =C5*D5
|
||||||
New-PSItem 12011 Crowbar 7 23.48 =C6*D6
|
New-PSItem 12011 Crowbar 7 23.48 =C6*D6
|
||||||
) | Export-Excel functions.xlsx -AutoSize -Show
|
) | Export-Excel functions.xlsx -AutoSize -Show
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
Remove-Item .\testFormula.xlsx -ErrorAction Ignore
|
Remove-Item .\testFormula.xlsx -ErrorAction Ignore
|
||||||
|
|
||||||
@"
|
@"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
. ..\New-PSItem.ps1
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
rm *.xlsx
|
Remove-Item *.xlsx
|
||||||
|
|
||||||
$(
|
$(
|
||||||
New-PSItem =2%/12 60 500000 "=pmt(rate,nper,pv)" (echo rate nper pv pmt)
|
New-PSItem =2%/12 60 500000 "=pmt(rate,nper,pv)" (echo rate nper pv pmt)
|
||||||
New-PSItem =3%/12 60 500000 "=pmt(rate,nper,pv)"
|
New-PSItem =3%/12 60 500000 "=pmt(rate,nper,pv)"
|
||||||
New-PSItem =4%/12 60 500000 "=pmt(rate,nper,pv)"
|
New-PSItem =4%/12 60 500000 "=pmt(rate,nper,pv)"
|
||||||
New-PSItem =5%/12 60 500000 "=pmt(rate,nper,pv)"
|
New-PSItem =5%/12 60 500000 "=pmt(rate,nper,pv)"
|
||||||
New-PSItem =6%/12 60 500000 "=pmt(rate,nper,pv)"
|
New-PSItem =6%/12 60 500000 "=pmt(rate,nper,pv)"
|
||||||
New-PSItem =7%/12 60 500000 "=pmt(rate,nper,pv)"
|
New-PSItem =7%/12 60 500000 "=pmt(rate,nper,pv)"
|
||||||
) | Export-Excel functions.xlsx -AutoNameRange -AutoSize -Show
|
) | Export-Excel functions.xlsx -AutoNameRange -AutoSize -Show
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
rm *.xlsx
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
Remove-Item *.xlsx
|
||||||
|
|
||||||
$(
|
$(
|
||||||
New-PSItem '=Hyperlink("http://dougfinke.com/blog","Doug Finke")' @("Link")
|
New-PSItem '=Hyperlink("http://dougfinke.com/blog","Doug Finke")' @("Link")
|
||||||
New-PSItem '=Hyperlink("http://blogs.msdn.com/b/powershell/","PowerShell Blog")'
|
New-PSItem '=Hyperlink("http://blogs.msdn.com/b/powershell/","PowerShell Blog")'
|
||||||
New-PSItem '=Hyperlink("http://blogs.technet.com/b/heyscriptingguy/","Hey, Scripting Guy")'
|
New-PSItem '=Hyperlink("http://blogs.technet.com/b/heyscriptingguy/","Hey, Scripting Guy")'
|
||||||
|
|
||||||
) | Export-Excel hyperlink.xlsx -AutoSize -Show
|
) | Export-Excel hyperlink.xlsx -AutoSize -Show
|
||||||
|
|||||||
BIN
Examples/SpreadsheetCells/hyperlink.xlsx
Normal file
BIN
Examples/SpreadsheetCells/hyperlink.xlsx
Normal file
Binary file not shown.
@@ -1,3 +1,7 @@
|
|||||||
|
<#
|
||||||
|
Revisit I think yahoo deprecated their service
|
||||||
|
#>
|
||||||
|
|
||||||
function Get-StockInfo {
|
function Get-StockInfo {
|
||||||
param(
|
param(
|
||||||
$stock,
|
$stock,
|
||||||
@@ -7,15 +11,15 @@ function Get-StockInfo {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
|
|
||||||
if(!$endDate) { $endDate = $startDate}
|
if (!$endDate) { $endDate = $startDate}
|
||||||
|
|
||||||
$baseUrl = "http://query.yahooapis.com/v1/public/yql?q="
|
$baseUrl = "http://query.yahooapis.com/v1/public/yql?q="
|
||||||
$q = @"
|
$q = @"
|
||||||
select * from yahoo.finance.historicaldata where symbol = "$($stock)" and startDate = "$($startDate.ToString('yyyy-MM-dd'))" and endDate = "$($endDate.ToString('yyyy-MM-dd'))"
|
select * from yahoo.finance.historicaldata where symbol = "$($stock)" and startDate = "$($startDate.ToString('yyyy-MM-dd'))" and endDate = "$($endDate.ToString('yyyy-MM-dd'))"
|
||||||
"@
|
"@
|
||||||
$suffix = "&env=store://datatables.org/alltableswithkeys&format=json"
|
$suffix = "&env=store://datatables.org/alltableswithkeys&format=json"
|
||||||
$r=Invoke-RestMethod ($baseUrl + $q + $suffix)
|
$r = Invoke-RestMethod ($baseUrl + $q + $suffix)
|
||||||
$r.query.results.quote
|
$r.query.results.quote
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,20 @@
|
|||||||
$Symbol = "MSFT"
|
<#
|
||||||
|
Revisit I think yahoo deprecated their service
|
||||||
|
#>
|
||||||
|
|
||||||
. .\Get-StockInfo.ps1
|
# try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
rm *.xlsx
|
# $Symbol = "MSFT"
|
||||||
|
|
||||||
$chart = New-ExcelChart -XRange Date -YRange Volume `
|
# . .\Get-StockInfo.ps1
|
||||||
-ChartType ColumnStacked `
|
|
||||||
-Column 9 -Title "$Symbol Volume"
|
|
||||||
|
|
||||||
Get-StockInfo $Symbol 11/2 11/30 |
|
# Remove-Item *.xlsx -ErrorAction Ignore
|
||||||
Export-Excel .\stocks.xlsx -Show `
|
|
||||||
-AutoSize -AutoNameRange `
|
# $chart = New-ExcelChart -XRange Date -YRange Volume `
|
||||||
-ExcelChartDefinition $chart
|
# -ChartType ColumnStacked `
|
||||||
|
# -Column 9 -Title "$Symbol Volume"
|
||||||
|
|
||||||
|
# Get-StockInfo $Symbol 11/2 11/30 |
|
||||||
|
# Export-Excel .\stocks.xlsx -Show `
|
||||||
|
# -AutoSize -AutoNameRange `
|
||||||
|
# -ExcelChartDefinition $chart
|
||||||
BIN
Examples/Stocks/stocks.xlsx
Normal file
BIN
Examples/Stocks/stocks.xlsx
Normal file
Binary file not shown.
@@ -1,38 +1,40 @@
|
|||||||
$xlfile = "testData.xlsx"
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
rm *.xlsx
|
|
||||||
|
|
||||||
$r = dir C:\WINDOWS\system32
|
$xlfile = "testData.xlsx"
|
||||||
|
Remove-Item *.xlsx
|
||||||
|
|
||||||
|
$r = Get-ChildItem C:\WINDOWS\system32
|
||||||
|
|
||||||
$BySize=@{}
|
$BySize=@{}
|
||||||
$r | ForEach{ $BySize.($_.extension)+=$_.length }
|
$r | ForEach-Object{ $BySize.($_.extension)+=$_.length }
|
||||||
|
|
||||||
$top10BySize = $BySize.GetEnumerator() |
|
$top10BySize = $BySize.GetEnumerator() |
|
||||||
ForEach{ [PSCustomObject]@{Name=$_.key;Size=[double]$_.value} } |
|
ForEach-Object{ [PSCustomObject]@{Name=$_.key;Size=[double]$_.value} } |
|
||||||
Sort size -Descending |
|
Sort-Object size -Descending |
|
||||||
Select -First 10
|
Select-Object -First 10
|
||||||
|
|
||||||
$top10ByCount = $r.extension |
|
$top10ByCount = $r.extension |
|
||||||
Group |
|
Group-Object |
|
||||||
Sort count -Descending |
|
Sort-Object count -Descending |
|
||||||
Select -First 10 Name, count
|
Select-Object -First 10 Name, count
|
||||||
|
|
||||||
$top10ByFileSize = $r |
|
$top10ByFileSize = $r |
|
||||||
Sort length -Descending |
|
Sort-Object length -Descending |
|
||||||
Select -First 10 Name, @{n="Size";e={$_.Length}} #,Extension,Path
|
Select-Object -First 10 Name, @{n="Size";e={$_.Length}} #,Extension,Path
|
||||||
|
|
||||||
|
|
||||||
$top10BySize | Export-Excel $xlfile -WorkSheetname FileInfo -TableName ExtSize
|
$top10BySize | Export-Excel $xlfile -WorkSheetname FileInfo -TableName ExtSize
|
||||||
$top10ByCount | Export-Excel $xlfile -WorkSheetname FileInfo -StartRow 13 -TableName ExtCount
|
$top10ByCount | Export-Excel $xlfile -WorkSheetname FileInfo -StartRow 13 -TableName ExtCount
|
||||||
$top10ByFileSize | Export-Excel $xlfile -WorkSheetname FileInfo -StartRow 25 -AutoSize -TableName FileSize
|
$top10ByFileSize | Export-Excel $xlfile -WorkSheetname FileInfo -StartRow 25 -AutoSize -TableName FileSize
|
||||||
|
|
||||||
$ps = ps | ? Company
|
$ps = Get-Process | Where-Object Company
|
||||||
|
|
||||||
$ps |
|
$ps |
|
||||||
sort handles -Descending |
|
Sort-Object handles -Descending |
|
||||||
select -First 10 company, handles |
|
Select-Object -First 10 company, handles |
|
||||||
Export-Excel $xlfile -WorkSheetname Handles -AutoSize -TableName Handles
|
Export-Excel $xlfile -WorkSheetname Handles -AutoSize -TableName Handles
|
||||||
|
|
||||||
$ps |
|
$ps |
|
||||||
sort PM -Descending |
|
Sort-Object PM -Descending |
|
||||||
select -First 10 company, PM |
|
Select-Object -First 10 company, PM |
|
||||||
Export-Excel $xlfile -WorkSheetname Handles -AutoSize -TableName PM -StartRow 13 -Show
|
Export-Excel $xlfile -WorkSheetname Handles -AutoSize -TableName PM -StartRow 13 -Show
|
||||||
|
|||||||
BIN
Examples/Tables/testData.xlsx
Normal file
BIN
Examples/Tables/testData.xlsx
Normal file
Binary file not shown.
@@ -1,10 +1,11 @@
|
|||||||
ipmo .\ImportExcel.psd1 -Force
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
|
||||||
. .\ConvertExcelToImageFile.ps1
|
. .\ConvertExcelToImageFile.ps1
|
||||||
|
|
||||||
$xlFileName = "C:\Temp\testPNG.xlsx"
|
$xlFileName = "C:\Temp\testPNG.xlsx"
|
||||||
|
|
||||||
rm C:\Temp\testPNG.xlsx -ErrorAction Ignore
|
Remove-Item C:\Temp\testPNG.xlsx -ErrorAction Ignore
|
||||||
|
|
||||||
$range = @"
|
$range = @"
|
||||||
Region,Item,Cost
|
Region,Item,Cost
|
||||||
@@ -16,8 +17,8 @@ North,Pear,1
|
|||||||
South,Apple,2
|
South,Apple,2
|
||||||
East,Grapes,3
|
East,Grapes,3
|
||||||
West,Berry,4
|
West,Berry,4
|
||||||
"@ | ConvertFrom-Csv |
|
"@ | ConvertFrom-Csv |
|
||||||
Export-Excel $xlFileName -ReturnRange `
|
Export-Excel $xlFileName -ReturnRange `
|
||||||
-ConditionalText (New-ConditionalText Apple), (New-ConditionalText Berry -ConditionalTextColor White -BackgroundColor Purple)
|
-ConditionalText (New-ConditionalText Apple), (New-ConditionalText Berry -ConditionalTextColor White -BackgroundColor Purple)
|
||||||
|
|
||||||
Convert-XlRangeToImage -Path $xlFileName -workSheetname sheet1 -range $range -Show
|
Convert-XlRangeToImage -Path $xlFileName -workSheetname sheet1 -range $range -Show
|
||||||
|
|||||||
Reference in New Issue
Block a user