You can easily add page breaks in rows and columns for files in OpenXML (.xlsx) format using the PageBreak property.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
C1XLBook1.Sheets(0)(2, 3).Value = "page1" C1XLBook1.Sheets(0).Rows(2).PageBreak = True C1XLBook1.Sheets(0)(0, 1).Value = "test1" C1XLBook1.Sheets(0)(0, 2).Value = "test2" C1XLBook1.Sheets(0).Columns(1).PageBreak = True C1XLBook1.Sheets(0)(3, 3).Value = "page2" ' Save and open the .xlsx file C1XLBook1.Save("c:\Save.xlsx") System.Diagnostics.Process.Start("c:\Save.xlsx") |
To write code in C#
C# |
Copy Code
|
---|---|
c1XLBook1.Sheets[0][2, 3].Value = "page1"; c1XLBook1.Sheets[0].Rows[2].PageBreak = true; c1XLBook1.Sheets[0][0, 1].Value = "test1"; c1XLBook1.Sheets[0][0, 2].Value = "test2"; c1XLBook1.Sheets[0].Columns[1].PageBreak = true; c1XLBook1.Sheets[0][3, 3].Value = "page2"; // Save and open the .xlsx file c1XLBook1.Save(@"c:\Save.xlsx"); System.Diagnostics.Process.Start(@"c:\Save.xlsx"); |