ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

Import-Excel 7.8.9 - Export Excel file with AutoSize function

Open bovirus opened this issue 1 year ago • 3 comments

My scope is to create an Execl file as table with columns autozize 8adapt column size to larger data vailable)

If I use a funcion like

Export-Excel -Path ExcelFile.xlsx -TableName Table1 -AutoSize"

I create a file ExcelFile.xlsx and openiong it I can check that the coumn size is not set automatically because if I sue in execl columns autozie the column are larger,.

What's the matter?

bovirus avatar Sep 07 '24 13:09 bovirus

need to see the data, script and what OS you are working on

dfinke avatar Sep 07 '24 23:09 dfinke

@dfinke

OS: Windows 10 22 H2 64bit italian

Scope of this process

open a csv sort csv on some fields remove some fierdls (tarspose) save it as Excel table

test.zip

The xlsx file created, opened with Execl 2013 and set column autozise have a larger columns.

If you have any sugegstion thanks.

bovirus avatar Sep 08 '24 07:09 bovirus

which columns have the issue?

-AutoSize is best guess. When the xlsx is opened, the cells are rendered and the font can result in the column widths being off.

$xlpkg = $data | Export-Excel test.xlsx -AutoSize -PassThru

Set-ExcelRange -Worksheet $xlpkg.Sheet1 -Range "C:C" -Width 22
Set-ExcelRange -Worksheet $xlpkg.Sheet1 -Range "E:E" -Width 32

Close-ExcelPackage $xlpkg -Show

dfinke avatar Sep 08 '24 14:09 dfinke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 04:04 stale[bot]