I'm working with the Office Interop and having trouble inserting page breaks in Excel. My code is working fine with the horizontal page break
but I also need to set the vertical pagebreak
. Can somone modify my code below, to make a vertical page break
on column I
?
This code is making the correct horizontal pagebreaks
but is still 150 pages long because the vertical pagebreak is not set correctly.
Dim r As Excel.Range = CType(xlWorkSheet.Cells(27, 1), Excel.Range)
r.PageBreak = 1
This
sheet.VPageBreaks.Add(sheet.Range["J1"]);
worked for me to set a vertical page break. As shown in the picture, it seems to put the page break before the specified column:
尝试为右列对象本身而不是单元格范围设置垂直分页符。
If you want page like A1:D15
for that
excelWorksheet.Range(E16).PageBreak = 1
It will create both vertical and horizontal page break.
This is just example. Code accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.