mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 15:53:32 +00:00
Added Read-Clipboard
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
RootModule = 'ImportExcel.psm1'
|
RootModule = 'ImportExcel.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '7.1.3'
|
ModuleVersion = '7.2.0'
|
||||||
|
|
||||||
# ID used to uniquely identify this module
|
# ID used to uniquely identify this module
|
||||||
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
||||||
@@ -78,7 +78,8 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
|||||||
'Open-ExcelPackage',
|
'Open-ExcelPackage',
|
||||||
'PieChart',
|
'PieChart',
|
||||||
'Pivot',
|
'Pivot',
|
||||||
'Remove-Worksheet'
|
'Read-Clipboard',
|
||||||
|
'Remove-Worksheet',
|
||||||
'Select-Worksheet',
|
'Select-Worksheet',
|
||||||
'Send-SQLDataToExcel',
|
'Send-SQLDataToExcel',
|
||||||
'Set-CellStyle',
|
'Set-CellStyle',
|
||||||
|
|||||||
53
Public/Read-Clipboard.ps1
Normal file
53
Public/Read-Clipboard.ps1
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
function Read-Clipboard {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Read text from clipboard and pass to either ConvertFrom-Csv or ConvertFrom-Json.
|
||||||
|
Check out the how to video - https://youtu.be/dv2GOH5sbpA
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Read text from clipboard. It is tuned to read tab delimited data. It can read CSV or JSON
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Read-Clipboard # delimter default is tab `t
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Read-Clipboard -Delimiter ',' # Converts CSV
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Read-Clipboard -AsJson # Converts JSON
|
||||||
|
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
$Delimiter = "`t",
|
||||||
|
$Header,
|
||||||
|
[Switch]$AsJson
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($IsWindows) {
|
||||||
|
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
|
||||||
|
if ($osInfo.ProductType -eq 1) {
|
||||||
|
$clipboardData = Get-Clipboard -Raw
|
||||||
|
if ($AsJson) {
|
||||||
|
ConvertFrom-Json -InputObject $clipboardData
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$cvtParams = @{
|
||||||
|
InputObject = $clipboardData
|
||||||
|
Delimiter = $Delimiter
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Header) {
|
||||||
|
$cvtParams.Header = $Header
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertFrom-Csv @cvtParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Error "This command is only supported on the desktop."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Error "This function is only available on Windows desktop"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user