mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Format datetime properties
This commit is contained in:
@@ -176,15 +176,20 @@ function Export-Excel {
|
||||
$ColumnIndex = 1
|
||||
|
||||
foreach ($Name in $Header) {
|
||||
$ws.Cells[$Row, $ColumnIndex].Value = $TargetData.$Name
|
||||
|
||||
$targetCell = $ws.Cells[$Row, $ColumnIndex]
|
||||
$targetCell.Value = $TargetData.$Name
|
||||
|
||||
switch ($TargetData.$Name) {
|
||||
{$_ -is [datetime]} {$targetCell.Style.Numberformat.Format = "m/d/yy h:mm"}
|
||||
}
|
||||
|
||||
$ColumnIndex += 1
|
||||
}
|
||||
}
|
||||
|
||||
End {
|
||||
|
||||
if($AutoSize) {$ws.Cells.AutoFitColumns()}
|
||||
|
||||
if($IncludePivotTable) {
|
||||
$pivotTableName = $WorkSheetname + "PivotTable"
|
||||
$wsPivot = $pkg.Workbook.Worksheets.Add($pivotTableName)
|
||||
@@ -223,6 +228,7 @@ function Export-Excel {
|
||||
}
|
||||
}
|
||||
|
||||
if($AutoSize) { $ws.Cells.AutoFitColumns() }
|
||||
if($Password) { $ws.Protection.SetPassword($Password) }
|
||||
|
||||
$pkg.Save()
|
||||
|
||||
Reference in New Issue
Block a user