Replies: 1 comment 1 reply
-
$bytes = [System.Text.Encoding]::UTF8.GetBytes($xlsx)This line is the problem. Maybe try (there's a few functions using Get-Member) $xlsx.GetAsByteArray() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to create the xlsx file to memory:
$xlsx = $SecurityGroups |Export-Excel -KillExcel -ClearSheet -Show -AutoSize -PivotRows GroupName,GroupMember -includePivotTable -PivotData GroupMember -WorksheetName "Groepen en Leden" -HideSheet "Groepen en Leden" -PivotTableName "GroepenEnLeden" -PassThruAfter the excel document object is created i convert it to a Base64 string:
$bytes = [System.Text.Encoding]::UTF8.GetBytes($xlsx)$b64 = [System.Convert]::ToBase64String($bytes)However, when i receive the mail it doesn't get me an Excel file, but a text file with this content: OfficeOpenXml.ExcelPackage
Is there a way to generate the excel file in memory, so i can attach it from the memory as attachment in the mail via Powershell?
The reason is that i do have a Powershell runspace, but i do not have the possibility to save it as a file. I work in an Azure Runbook.
Beta Was this translation helpful? Give feedback.
All reactions