Updates to Help text - mostly layout, inc making it VSCode freindly

This commit is contained in:
jhoneill
2018-07-10 13:43:15 +01:00
parent 9a81ddeebd
commit bfbba90c44
11 changed files with 155 additions and 178 deletions

View File

@@ -32,14 +32,14 @@
[Parameter(Mandatory = $true, ParameterSetName = "FourIconSet")]
[Parameter(Mandatory = $true, ParameterSetName = "FiveIconSet")]
[OfficeOpenXml.ExcelAddress]$Range ,
#One or more row(s), Column(s) and/or block(s) of cells to format
#One or more row(s), column(s) and/or block(s) of cells to format
[Parameter(Mandatory = $true, ParameterSetName = "NamedRuleAddress")]
[Parameter(Mandatory = $true, ParameterSetName = "DataBarAddress")]
[Parameter(Mandatory = $true, ParameterSetName = "ThreeIconSetAddress")]
[Parameter(Mandatory = $true, ParameterSetName = "FourIconSetAddress")]
[Parameter(Mandatory = $true, ParameterSetName = "FiveIconSetAddress")]
$Address ,
#One of the standard named rules - Top / Bottom / Less than / Greater than / Contains etc
#One of the standard named rules - Top / Bottom / Less than / Greater than / Contains etc.
[Parameter(Mandatory = $true, ParameterSetName = "NamedRule", Position = 3)]
[Parameter(Mandatory = $true, ParameterSetName = "NamedRuleAddress", Position = 3)]
[OfficeOpenXml.ConditionalFormatting.eExcelConditionalFormattingRuleType]$RuleType ,
@@ -65,7 +65,7 @@
[OfficeOpenXml.ConditionalFormatting.eExcelconditionalFormatting5IconsSetType]$FiveIconsSet,
#A value for the condition (e.g. "2000" if the test is 'lessthan 2000')
[string]$ConditionValue,
#A second value for the conditions like between x and Y
#A second value for the conditions like "between x and Y"
[string]$ConditionValue2,
#Background colour for matching items
[System.Drawing.Color]$BackgroundColor,

View File

@@ -1,5 +1,5 @@
Function Convert-XlRangeToImage {
<#
<#
.Synopsis
Gets the specified part of an Excel file and exports it as an image
.Description
@@ -10,8 +10,8 @@
* Saves the clipboard contents as an image file (it will save as .JPG unless the file name ends .BMP or .PNG)
* Copies a single cell to the clipboard (to prevent the "you have put a lot in the clipboard" message appearing)
* Closes Excel
#>
Param (
#>
Param (
#Path to the Excel file
[parameter(Mandatory=$true)]
$Path,
@@ -24,7 +24,7 @@ Param (
$destination = "$pwd\temp.png",
#If specified opens the image in the default viewer.
[switch]$show
)
)
$extension = $destination -replace '^.*\.(\w+)$' ,'$1'
if ($extension -in @('JPEG','BMP','PNG')) {
$Format = [system.Drawing.Imaging.ImageFormat]$extension

View File

@@ -14,12 +14,12 @@ function ConvertFrom-ExcelData {
}
$reportRecord +=""
$reportRecord -join "`r`n"
}
}
First: John
Last: Doe
The Zip: 12345
....
First: John
Last: Doe
The Zip: 12345
....
#>
param(
[Alias("FullName")]

View File

@@ -2,47 +2,30 @@ function ConvertFrom-ExcelToSQLInsert {
<#
.SYNOPSIS
Generate SQL insert statements from Excel spreadsheet.
.DESCRIPTION
Generate SQL insert statements from Excel spreadsheet.
.PARAMETER TableName
Name of the target database table.
.PARAMETER Path
Path to an existing .XLSX file
This parameter is passed to Import-Excel as is.
.PARAMETER WorkSheetname
Specifies the name of the worksheet in the Excel workbook to import. By default, if no name is provided, the first worksheet will be imported.
This parameter is passed to Import-Excel as is.
.PARAMETER StartRow
The row from where we start to import data, all rows above the StartRow are disregarded. By default this is the first row.
When the parameters -NoHeader and -HeaderName are not provided, this row will contain the column headers that will be used as property names. When one of both parameters are provided, the property names are automatically created and this row will be treated as a regular row containing data.
.PARAMETER Header
Specifies custom property names to use, instead of the values defined in the column headers of the TopRow.
In case you provide less header names than there is data in the worksheet, then only the data with a corresponding header name will be imported and the data without header name will be disregarded.
In case you provide more header names than there is data in the worksheet, then all data will be imported and all objects will have all the property names you defined in the header names. As such, the last properties will be blanc as there is no data for them.
If you provide fewr header names than there is data in the worksheet, then only the data with a corresponding header name will be imported and the data without header name will be disregarded.
If you provide more header names than there is data in the worksheet, then all data will be imported and all objects will have all the property names you defined in the header names. As such, the last properties will be blank as there is no data for them.
.PARAMETER NoHeader
Automatically generate property names (P1, P2, P3, ..) instead of the ones defined in the column headers of the TopRow.
This switch is best used when you want to import the complete worksheet as is and are not concerned with the property names.
.PARAMETER DataOnly
Import only rows and columns that contain data, empty rows and empty columns are not imported.
.PARAMETER ConvertEmptyStringsToNull
If specified, cells without any data are replaced with NULL, instead of an empty string.
This is to address behviors in certain DBMS where an empty string is insert as 0 for INT column, instead of a NULL value.
.EXAMPLE
@@ -85,7 +68,6 @@ function ConvertFrom-ExcelToSQLInsert {
INSERT INTO Movies ('Movie Name', 'Year', 'Rating') Values('Skyfall', '2012', '9');
INSERT INTO Movies ('Movie Name', 'Year', 'Rating') Values('The Avengers', '2012', NULL);
.NOTES
#>
[CmdletBinding()]
param(

View File

@@ -2,7 +2,7 @@
.Synopsis
Exports the charts in an Excel spreadSheet
.Example
Export-Charts .\test,xlsx
Export-Charts .\test.xlsx
Exports the charts in test.xlsx to JPEG files in the current directory.
.Example
@@ -13,7 +13,7 @@
Param (
#Path to the Excel file whose chars we will export.
$Path = "C:\Users\public\Documents\stats.xlsx",
#If specified, output file objects representing the image files.
#If specified, output file objects representing the image files
[switch]$Passthru,
#Format to write - JPG by default
[ValidateSet("JPG","PNG","GIF")]

View File

@@ -2,13 +2,10 @@ Function Get-ExcelSheetInfo {
<#
.SYNOPSIS
Get worksheet names and their indices of an Excel workbook.
.DESCRIPTION
The Get-ExcelSheetInfo cmdlet gets worksheet names and their indices of an Excel workbook.
.PARAMETER Path
Specifies the path to the Excel file. This parameter is required.
.EXAMPLE
Get-ExcelSheetInfo .\Test.xlsx
@@ -18,7 +15,6 @@ Function Get-ExcelSheetInfo {
.LINK
https://github.com/dfinke/ImportExcel
#>
[CmdletBinding()]

View File

@@ -2,13 +2,10 @@
<#
.SYNOPSIS
Retrieve information of an Excel workbook.
.DESCRIPTION
The Get-ExcelWorkbookInfo cmdlet retrieves information (LastModifiedBy, LastPrinted, Created, Modified, ...) fron an Excel workbook. These are the same details that are visible in Windows Explorer when right clicking the Excel file, selecting Properties and check the Details tabpage.
.PARAMETER Path
Specifies the path to the Excel file. This parameter is required.
.EXAMPLE
Get-ExcelWorkbookInfo .\Test.xlsx

View File

@@ -1,5 +1,5 @@
Function Set-Column {
<#
<#
.SYNOPSIS
Adds a column to the existing data area in an Excel sheet, fills values and sets formatting
.DESCRIPTION
@@ -11,21 +11,22 @@
C:> Set-Column -Worksheet $ws -Heading "WinsToFastLaps" -Value {"=E$row/C$row"} -Column 7 -AutoSize -AutoNameRange
Here $WS already contains a worksheet which contains counts of races won and fastest laps recorded by racing drivers (in columns C and E)
Set-Column specifies that Column 7 should have a heading of "WinsToFastLaps" and the data cells should contain =E2/C2 , =E3/C3
the data celss should become a named range, which will also be "WinsToFastLaps" the column width will be set automatically
#>
[cmdletbinding()]
the data cells should become a named range, which will also be "WinsToFastLaps" the column width will be set automatically
#>
[cmdletbinding()]
Param (
[Parameter(ParameterSetName="Package",Mandatory=$true)]
[OfficeOpenXml.ExcelPackage]$ExcelPackage,
#Sheet to update
#The sheet to update can be a given as a name or an Excel Worksheet object - this sets it by name
[Parameter(ParameterSetName="Package")]
#The sheet to update can be a given as a name or an Excel Worksheet object - $workSheet contains the object
$Worksheetname = "Sheet1",
[Parameter(ParameterSetName="sheet",Mandatory=$true)]
[OfficeOpenXml.ExcelWorksheet]
$Worksheet,
#Column to fill down - first column is 1. 0 will be interpreted as first unused column
$Column = 0 ,
#First row to fill data in
[Int]$StartRow ,
#value, formula or script block for to fill in. Script block can use $row, $column [number], $ColumnName [letter(s)], $startRow, $startColumn, $endRow, $endColumn
[parameter(Mandatory=$true)]
@@ -76,8 +77,9 @@
[Switch]$AutoSize,
#Set cells to a fixed width, ignored if Autosize is specified
[float]$Width,
#Set the inserted data to be a named range (ignored if header is not specified) d
#Set the inserted data to be a named range (ignored if header is not specified)
[Switch]$AutoNameRange,
#If Specified, return an ExcelPackage object to allow further work to be done on the file.
[switch]$PassThru
)
#if we were passed a package object and a worksheet name , get the worksheet.

View File

@@ -1,13 +1,13 @@
Function Set-Row {
<#
.Synopsis
<#
.Synopsis
Fills values into a row in a Excel spreadsheet
.Description
.Description
Set-Row accepts either a Worksheet object or an Excel package object returned by Export-Excel and the name of a sheet,
and inserts the chosen contents into a row of the sheet.
The contents can be a constant "42" , a formula or a script block which is converted into a constant or formula.
The first cell of the row can optional be given a heading.
.Example
.Example
Set-row -Worksheet $ws -Heading Total -Value {"=sum($columnName`2:$columnName$endrow)" }
$Ws contains a worksheet object, and no Row number is specified so Set-Row will select the next row after the end of the data in the sheet
@@ -15,10 +15,8 @@
=Sum(xx2:xx99) - where xx is the column name, and 99 is the last row of data.
Note the use of `2 to Prevent 2 becoming part of the variable "ColumnName"
The script block can use $row, $column, $ColumnName, $startRow/Column $endRow/Column
#>
[cmdletbinding()]
#>
[cmdletbinding()]
Param (
#An Excel package object - e.g. from Export-Excel -passthru - requires a sheet name
[Parameter(ParameterSetName="Package",Mandatory=$true)]
@@ -75,11 +73,12 @@
[OfficeOpenXml.Style.ExcelHorizontalAlignment]$HorizontalAlignment,
#Position cell contents to top bottom or centre
[OfficeOpenXml.Style.ExcelVerticalAlignment]$VerticalAlignment,
#Degrees to rotate text. Up to +90 for anti-clockwise ("upwards"), or to -90 for clockwise.
#Degrees to rotate text. Up to +90 for anti-clockwise ("upwards"), or to -90 for clockwise
[ValidateRange(-90, 90)]
[int]$TextRotation ,
#Set cells to a fixed hieght
[float]$Height,
#If Specified, return an ExcelPackage object to allow further work to be done on the file
[switch]$PassThru
)

View File

@@ -72,7 +72,8 @@ Function Update-FirstObjectProperties {
.NOTES
CHANGELOG
2017/06/08 Function born #>
2017/06/08 Function born
#>
Try {
$Union = @()

View File

@@ -1,8 +1,8 @@
Function Add-ConditionalFormatting {
<#
.Synopsis
<#
.Synopsis
Adds contitional formatting to worksheet
.Example
.Example
$excel = $avdata | Export-Excel -Path (Join-path $FilePath "\Machines.XLSX" ) -WorksheetName "Server Anti-Virus" -AutoSize -FreezeTopRow -AutoFilter -PassThru
Add-ConditionalFormatting -WorkSheet $excel.Workbook.Worksheets[1] -Address "b":b1048576" -ForeGroundColor "RED" -RuleType ContainsText -ConditionValue "2003"
@@ -16,7 +16,7 @@
Fixed formats are then applied to dates in columns D..G and the top row is formatted
Finally the workbook is saved and the Excel closed.
#>
#>
Param (
#The worksheet where the format is to be applied
[OfficeOpenXml.ExcelWorksheet]$WorkSheet ,
@@ -89,17 +89,17 @@
}
Function Set-Format {
<#
.SYNOPSIS
<#
.SYNOPSIS
Applies Number, font, alignment and colour formatting to a range of Excel Cells
.EXAMPLE
.EXAMPLE
$sheet.Column(3) | Set-Format -HorizontalAlignment Right -NumberFormat "#,###"
Selects column 3 from a sheet object (within a workbook object, which is a child of the ExcelPackage object) and passes it to Set-Format which formats as an integer with comma seperated groups
.EXAMPLE
.EXAMPLE
Set-Format -Address $sheet.Cells["E1:H1048576"] -HorizontalAlignment Right -NumberFormat "#,###"
Instead of piping the address in this version specifies a block of cells and applies similar formatting
#>
#>
Param (
#One or more row(s), Column(s) and/or block(s) of cells to format
[Parameter(ValueFromPipeline=$true)]