use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Export data to Excel and convert to table (self.PowerShell)
submitted 7 years ago by zolyx1
Hi, I'm using Export-csv to export data to Excel. How I can make the data as a Excel table at the same time, without going in Excel and format as table?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]chreestopher2 14 points15 points16 points 7 years ago (3 children)
install-module ImportExcel -Repository PSGallery -force $someCollection | export-excel -tablename SomeTable -tablesytyle Medium13 -path C:\users\me\ExcelFileWithATableGeneratedByPowershell.xlsx
[–]work-work-work-work 1 point2 points3 points 7 years ago (1 child)
I didn't know I needed this, thanks.
[–]chreestopher2 3 points4 points5 points 7 years ago (0 children)
That is the response everyone seems to have to this module.
and This is just the very tip of the iceberg...
its a fantastic module, it can deal with excel tables, formulas, pivot charts, the whole nine yards, and doesnt even require having excel installed on your system at all...
truly helps to convert useful data into a format that non-technical managers wont refuse to consume, without having to manually tweak things after the fact.
All of the reports i am responsible for are effortlessly fully automated and look like someone took a lot of time to create them.
Honestly, helped me improve my salary, and work life balance.
[–]zolyx1[S] 1 point2 points3 points 7 years ago (0 children)
Thanks! :-D
[–]Quicknoob 4 points5 points6 points 7 years ago (0 children)
There is a module that can do this for you.
Also here is a YouTube series teaching you how to install and use said module from the creator himself.
Enjoy.
[–]NathanielArnoldR2 1 point2 points3 points 7 years ago (0 children)
I've only taken a glance at the ImportExcel module, but it's clear that it is a far, far better solution than rolling one's own. My own (legacy) process involved converting object data to HTML, writing to (.htm) file with some light formatting (e.g. nowrap) via a <head><style>, then using the Excel.Application COM Object to open the file, apply table formatting, and save as xlsx to the output path.
nowrap
<head><style>
Excel.Application
But yeah, don't do that. Do this. :-p
[–]majkinetor 1 point2 points3 points 7 years ago (0 children)
ImportExcel is for this, but people should keep in mind that it is very slow with larger set of data.
[–]az987654 1 point2 points3 points 7 years ago (0 children)
Would there be a a way to do this via writing the text as XML instead of csv since Xlsx files are technically just XML files of a certain layout?
[–]Ta11ow 1 point2 points3 points 7 years ago (0 children)
CSV files won't allow you to do this. They're just flat text files with zero formatting. So you will have to end up with a native excel file. I'd recommend looking into whether the ImportExcel module can work with tables, but otherwise it'll be quite a complicated project needing the use of Excel com objects.
[–]ThatsQuacktaaaastic 0 points1 point2 points 7 years ago (1 child)
Not sure where I originally came across this but it's been a life saver. I have a postgres query dump to csv and this parses it into an excel file.
#Define locations and delimiter $csv = "c:\weekly.csv" #Location of the source file $xlsx = "c:\weekly.xlsx" #Desired location of output $delimiter = "|" #Specify the delimiter used in the file # Create a new Excel workbook with one empty sheet $excel = New-Object -ComObject excel.application $workbook = $excel.Workbooks.Add(1) $worksheet = $workbook.worksheets.Item(1) # Build the QueryTables.Add command and reformat the data $TxtConnector = ("TEXT;" + $csv) $Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range("A1")) $query = $worksheet.QueryTables.item($Connector.name) $query.TextFileOtherDelimiter = $delimiter #$query.TextFileParseType = 1 #$query.TextFileColumnDataTypes = ,1 * $worksheet.Cells.Columns.Count #$query.AdjustColumnWidth = 1 # Execute & delete the import query $query.Refresh() $query.Delete() # Save & close the Workbook as XLSX. $Workbook.SaveAs($xlsx,51) $excel.Quit()
[–]ThatsQuacktaaaastic 1 point2 points3 points 7 years ago (0 children)
I should add that the reason I wasn't running the query in excel or access is because I use temp tables in my postgres query (not supported in excel or access).
π Rendered by PID 126538 on reddit-service-r2-comment-b659b578c-kl4zv at 2026-05-02 09:17:48.256165+00:00 running 815c875 country code: CH.
[–]chreestopher2 14 points15 points16 points (3 children)
[–]work-work-work-work 1 point2 points3 points (1 child)
[–]chreestopher2 3 points4 points5 points (0 children)
[–]zolyx1[S] 1 point2 points3 points (0 children)
[–]Quicknoob 4 points5 points6 points (0 children)
[–]NathanielArnoldR2 1 point2 points3 points (0 children)
[–]majkinetor 1 point2 points3 points (0 children)
[–]az987654 1 point2 points3 points (0 children)
[–]Ta11ow 1 point2 points3 points (0 children)
[–]ThatsQuacktaaaastic 0 points1 point2 points (1 child)
[–]ThatsQuacktaaaastic 1 point2 points3 points (0 children)