mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 13:23:29 +00:00
first pass
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.8.4'
|
ModuleVersion = '7.8.5'
|
||||||
|
|
||||||
# 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'
|
||||||
@@ -54,6 +54,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
|||||||
'Export-Excel',
|
'Export-Excel',
|
||||||
'Export-ExcelSheet',
|
'Export-ExcelSheet',
|
||||||
'Get-ExcelColumnName',
|
'Get-ExcelColumnName',
|
||||||
|
'Get-ExcelFileSchema',
|
||||||
'Get-ExcelFileSummary',
|
'Get-ExcelFileSummary',
|
||||||
'Get-ExcelSheetDimensionAddress',
|
'Get-ExcelSheetDimensionAddress',
|
||||||
'Get-ExcelSheetInfo',
|
'Get-ExcelSheetInfo',
|
||||||
|
|||||||
47
Public/Get-ExcelFileSchema.ps1
Normal file
47
Public/Get-ExcelFileSchema.ps1
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
function Get-ExcelFileSchema {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the schema of an Excel file.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
The Get-ExcelFileSchema function gets the schema of an Excel file by returning the property names of the first row of each worksheet in the file.
|
||||||
|
|
||||||
|
.PARAMETER Path
|
||||||
|
Specifies the path to the Excel file.
|
||||||
|
|
||||||
|
.PARAMETER Compress
|
||||||
|
Indicates whether to compress the json output.
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
Json
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ExcelFileSchema -Path .\example.xlsx
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName, Mandatory)]
|
||||||
|
[Alias('FullName')]
|
||||||
|
$Path,
|
||||||
|
[Switch]$Compress
|
||||||
|
)
|
||||||
|
|
||||||
|
Begin {
|
||||||
|
$result = @()
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
$excelFiles = Get-ExcelFileSummary $Path
|
||||||
|
|
||||||
|
foreach ($excelFile in $excelFiles) {
|
||||||
|
$data = Import-Excel $Path -WorksheetName $excelFile.WorksheetName | Select-Object -First 1
|
||||||
|
$names = $data[0].PSObject.Properties.name
|
||||||
|
$result += $excelFile | Add-Member -MemberType NoteProperty -Name "PropertyNames" -Value $names -PassThru
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
End {
|
||||||
|
$result | ConvertTo-Json -Compress:$Compress
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
# 7.8.5
|
||||||
|
|
||||||
|
- Added `Get-ExcelFileSchema` to get the schema of an Excel file.
|
||||||
|
- `Get-ExcelFileSchema -Path $xlfile`
|
||||||
|
|
||||||
# 7.8.x
|
# 7.8.x
|
||||||
|
|
||||||
Thanks to [Thomas Hofkens](https://github.com/thkn-hofa)
|
Thanks to [Thomas Hofkens](https://github.com/thkn-hofa)
|
||||||
|
|||||||
Reference in New Issue
Block a user