Skip to content

Instantly share code, notes, and snippets.

@altrive
Last active January 4, 2016 02:49
Show Gist options
  • Select an option

  • Save altrive/8557372 to your computer and use it in GitHub Desktop.

Select an option

Save altrive/8557372 to your computer and use it in GitHub Desktop.
Sample code to output excel file using ClosedXML
Use-NuGetPackage -PackageId ClosedXML -Verbose
#Set .Net current path
[IO.Directory]::SetCurrentDirectory((Get-Location).Path)
#Output Excel file to current directory
$workbook = New-Object ClosedXML.Excel.XLWorkbook
$worksheet = $workbook.Worksheets.Add("Sample Sheet");
$worksheet.Cell("A1").Value = "Hello World!";
$workbook.SaveAs("HelloWorld.xlsx");
$worksheet.Dispose()
#Open Excel File
explorer "HelloWorld.xlsx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment