Blog Post

SQL Server – Powershell Excel to HTML

,

SQL Server, Powershell and Excel are a good mix . But saving to Powershell output to HTML is versatile – if requiring email attachments or publishing results to a web page .

 Any Powershell scripts using Excel as an end point can be converted to HTML with just a few lines of code.  Therefore you can keep the Powershell \  Excel code , and add some lines for HTML output.

 The convert process , creates well formatted HTML pages , ideal for reports.  Creating the reports in HTML makes them easier to read on my smartphone – which does a better job at web browsing rather than reading Excel

 

$xlHtml = 44
$omit = [type]::Missing
$Excel = New-Object -ComObject Excel.Application
--some activity e.g recordsets 
--would normally save Excel as :
--$EXcel.ActiveWorkbook.SaveAs("c:myfile.xls")
--instead save the workbook as html
$EXcel.ActiveWorkbook.SaveAs("c:myfile.html",$xlHtml,$omit,$omit,$omit,$omit,$omit,$omit,$omit,$omit,$omit,$omit)
$Excel.Quit()

 

See Also

Powershell , Excel charts and data presentation

Powershell to HTML

Powershell sql server security audit

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating