excelxmlpowershellmodulepage-break

Add page break in excel with the module ImportExcel (Powershell)


I'm actually trying to generate a large report with multiple groups in powershell. I want to seperate each groups of data in a single page, but I'm struggling to find the method to add a horizontal page break with the ImportExcel module.

I'm starting to wonder if it is doable. I know that it is possible with the excel interlop com object, but the script with be run with an elevated user right on a server, so we do not want to install excel on to.

So far I've look at the module methods and I did not find anything. It seems like we have access to the document/sheets xml so if someone knows how to do it in xml, it could also do the trick.


Solution

  • I'll post my answer since I found it. The module ImportExcel is based on the EPPLUS library for c#.

    I've take a look in the library and there is a way to add a break line fairy easly, but does not show in powershell.

    $Sheet.Row($line).PageBreak = $true
    

    It's that simple. There is just not obvious documentation and the intellisense was not finding it too.