mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 05:13:49 +00:00
Update
This commit is contained in:
@@ -24,10 +24,8 @@ function Export-Excel {
|
||||
[bool]$TitleBold,
|
||||
[int]$TitleSize=22,
|
||||
[System.Drawing.Color]$TitleBackgroundColor,
|
||||
#[string]$TitleBackgroundColor,
|
||||
[string[]]$PivotRows,
|
||||
[string[]]$PivotColumns,
|
||||
#[string[]]$PivotData,
|
||||
$PivotData,
|
||||
[string]$Password,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="Pie",
|
||||
@@ -54,7 +52,7 @@ function Export-Excel {
|
||||
|
||||
$ws = $pkg | Add-WorkSheet -WorkSheetname $WorkSheetname -NoClobber:$NoClobber
|
||||
|
||||
foreach($format in $ConditionalFormat ) {
|
||||
foreach($format in $ConditionalFormat ) {
|
||||
#$obj = [PSCustomObject]@{
|
||||
# Address = $Address
|
||||
# Formatter = $ConditionalFormat
|
||||
|
||||
@@ -5,7 +5,7 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
|
||||
|
||||
function Import-Excel {
|
||||
param(
|
||||
[Alias("FullName")]
|
||||
[Alias("FullName")]
|
||||
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory)]
|
||||
$Path,
|
||||
$Sheet=1,
|
||||
@@ -16,8 +16,8 @@ function Import-Excel {
|
||||
|
||||
$Path = (Resolve-Path $Path).Path
|
||||
write-debug "target excel file $Path"
|
||||
|
||||
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,"Open","Read","ReadWrite"
|
||||
|
||||
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,"Open","Read","ReadWrite"
|
||||
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
|
||||
|
||||
$workbook = $xl.Workbook
|
||||
@@ -39,14 +39,14 @@ function Import-Excel {
|
||||
foreach ($Column in 0..($Columns-1)) {
|
||||
if($Header[$Column].Length -gt 0) {
|
||||
$Name = $Header[$Column]
|
||||
$h.$Name = $worksheet.Cells[$Row,($Column+1)].Value
|
||||
$h.$Name = $worksheet.Cells[$Row,($Column+1)].Text
|
||||
}
|
||||
}
|
||||
[PSCustomObject]$h
|
||||
}
|
||||
|
||||
$stream.Close()
|
||||
$stream.Dispose()
|
||||
|
||||
$stream.Close()
|
||||
$stream.Dispose()
|
||||
$xl.Dispose()
|
||||
$xl = $null
|
||||
}
|
||||
@@ -134,7 +134,7 @@ function ConvertFrom-ExcelSheet {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Alias("FullName")]
|
||||
[Alias("FullName")]
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
@@ -151,7 +151,7 @@ function ConvertFrom-ExcelSheet {
|
||||
)
|
||||
|
||||
$Path = (Resolve-Path $Path).Path
|
||||
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,"Open","Read","ReadWrite"
|
||||
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,"Open","Read","ReadWrite"
|
||||
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
|
||||
$workbook = $xl.Workbook
|
||||
|
||||
@@ -170,9 +170,9 @@ function ConvertFrom-ExcelSheet {
|
||||
|
||||
Import-Excel $Path -Sheet $($sheet.Name) | Export-Csv @params -Encoding $Encoding
|
||||
}
|
||||
|
||||
$stream.Close()
|
||||
$stream.Dispose()
|
||||
|
||||
$stream.Close()
|
||||
$stream.Dispose()
|
||||
$xl.Dispose()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user