ExcelWriter supports in the insertion of horizontal and vertical page breaks within a Worksheet using the ExcelApplication class/object. It does not, however, support the deletion or modification of existing page breaks.
Horizontal page breaks
To insert a horizontal page break, use one of the following methods:
| ExcelApplication platform |
Method |
| .NET or Java |
Worksheet.InsertHorizontalPageBreak(Cell afterCell) |
| COM/ASP * |
SACells.HPageBreak(Cell As SACell) |
* Includes SAExcelApplicationDotNet wrapper class used in ASP.NET
Vertical page breaks
To insert a vertical page break, use one of the following methods:
| ExcelApplication platform |
Method |
| .NET or Java |
Worksheet.InsertVerticalPageBreak(Cell rightOfCell) |
| COM/ASP * |
SACells.VPageBreak(Cell As SACell) |
* Includes SAExcelApplicationDotNet wrapper class used in ASP.NET
Examples
The following examples demonstrate inserting a horizontal page break and a vertical page break.
|
[C#]
|
[VB.NET]
|
[Java]
|
[COM/ASP]
|
|
//--- The following namespace has been imported:
//--- SoftArtisans.OfficeWriter.ExcelWriter
//--- Instantiate ExcelApplication and create a new Workbook
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create();
Worksheet sheet1 = wb.Worksheets[0];
//--- Insert horizontal page break below cell A15
sheet1.InsertHorizontalPageBreak(sheet1.Cells["A15"]);
//--- Insert vertical page break to the right of cell H1
sheet1.InsertVerticalPageBreak(sheet1.Cells["H1"]);
//--- Save Workbook
xla.Save(wb, Response, "out.xls", false);
'--- The following namespace has been imported:
'--- SoftArtisans.OfficeWriter.ExcelWriter
'--- Instantiate ExcelApplication and create a new Workbook
Dim xla As New ExcelApplication
Dim wb As Workbook = xla.Create()
Dim sheet1 As Worksheet = wb.Worksheets(0)
'--- Insert horizontal page break below cell A15
sheet1.InsertHorizontalPageBreak(sheet1.Cells("A15"))
'--- Insert vertical page break to the right of cell H1
sheet1.InsertVerticalPageBreak(sheet1.Cells("H1"))
'--- Save Workbook
xla.Save(wb, Response, "out.xls", False)
//--- The following package has been imported:
//--- com.softartisans.excelwriter.*
//--- Instantiate ExcelApplication and create a new Workbook
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.create();
Worksheet sheet1 = wb.getWorksheet(0);
//--- Insert horizontal page break below cell A15
sheet1.insertHorizontalPageBreak(sheet1.getCell("A15");
//--- Insert vertical page break to the right of cell H1
sheet1.insertVerticalPageBreak(sheet1.getCell("H1");
//--- Save Workbook
xla.save(wb, response, "out.xls", false);
'--- Instantiate ExcelApplication and create a new Workbook
Set xla = Server.CreateObject("SoftArtisans.ExcelWriter")
Set sheet1 = xla.Worksheets(1)
Set cells = sheet1.Cells
'--- Insert horizontal page break below cell A15
cells.HPageBreak cells("A15")
'--- Insert vertical page break to the right of cell H1
cells.VPageBreak cells("H1")
'--- Save Workbook
xla.Save("out.xls", SASaveMethod.saOpenInExcel, _
SAFileFormat.saFileFormatDefault, Response);
|
|