Skip to content

csv to excel export-excel with filter option date field conversions #1473

Answered by sammysammyss
sammysammyss asked this question in Q&A
Discussion options

You must be logged in to vote

I found the solution to my problem. Just posting here for anyone else like me who doesn't fully understand all the importexcel options :)

I generate my file just like normal into an excel format:

$data|Export-Excel -AutoSize -NoNumberConversion $stringcolumns -TableStyle Medium13 -path $path'.xlsx'

Then I use the open-excelpackage to modify the format of my date fields:

$excel = Open-ExcelPackage $path'.xlsx'
$ws = $excel.Workbook.Worksheets[1]
$datecolumnnumbers = $excel.sheet1.tables.columns |where name -like $datecolumns |select -ExpandProperty id

#change date columns to friendly format
foreach ($num in $datecolumnnumbers){
Set-ExcelRange -address $ws.column($num) -numberFormat 'd-mmm-…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sammysammyss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant