Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set page layout break on worksheet using EPPlus

Is there a way to set specify where to break the page using EEPlus? I have the following code that sets the printer properties but haven't found a way to set a break point on a certain column.

// Set printer settings
ws.PrinterSettings.PaperSize = ePaperSize.Tabloid;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.FitToPage = true;
ws.PrinterSettings.FitToHeight = 1;
ws.PrinterSettings.FooterMargin = .05M;
ws.PrinterSettings.TopMargin = .05M;
ws.PrinterSettings.LeftMargin = .05M;
ws.PrinterSettings.RightMargin = .05M;

Edit (this helped solve my problem)

ws.Column(30).PageBreak = true;
ws.PrinterSettings.PaperSize = ePaperSize.A3;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.Scale = 75;  
like image 887
thatstevedude Avatar asked Feb 02 '16 18:02

thatstevedude


1 Answers

Just need to get reference to the Row and/or Column objects:

ws.Row(20).PageBreak = true;
ws.Column(2).PageBreak = true;

But keep in mind that FitToPage might suppress these.

like image 68
Ernie S Avatar answered Oct 13 '22 01:10

Ernie S