在Ruby中管理分页符
Contents
[
Hide
]
Aspose.Cells - 管理分页符
添加分页
使用Aspose.Cells Java for Ruby添加分页符,请调用pagebreaks模块的add_page_breaks方法。下面是代码示例。
Ruby 代码
def add_page_breaks(workbook)
worksheets = workbook.getWorksheets()
worksheet = worksheets.get(0)
h_page_breaks = worksheet.getHorizontalPageBreaks()
h_page_breaks.add("Y30")
v_page_breaks = worksheet.getVerticalPageBreaks()
v_page_breaks.add("Y30")
# Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(@data_dir + "Add Page Breaks.xls")
puts "Add page breaks, please check the output file."
end
清除所有分页符
使用Aspose.Cells Java for Ruby清除所有分页符,请调用pagebreaks模块的clear_all_page_breaks方法。下面是代码示例。
Ruby 代码
def clear_all_page_breaks(workbook)
workbook.getWorksheets().get(0).getHorizontalPageBreaks().clear()
workbook.getWorksheets().get(0).getVerticalPageBreaks().clear()
# Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(@data_dir + "Clear All Page Breaks.xls")
puts "Clear all page breaks, please check the output file."
end
移除特定分页符
使用Aspose.Cells Java for Ruby移除特定分页符,请调用pagebreaks模块的remove_page_break方法。下面是代码示例。
Ruby 代码
def remove_page_break(workbook)
worksheets = workbook.getWorksheets()
worksheet = worksheets.get(0)
h_page_breaks = worksheet.getHorizontalPageBreaks()
h_page_breaks.removeAt(0)
v_page_breaks = worksheet.getVerticalPageBreaks()
v_page_breaks.removeAt(0)
# Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(@data_dir + "Remove Page Break.xls")
puts "Remove page break, please check the output file."
end
下载运行代码
从以下任何社交编程网站下载管理分页符(Aspose.Cells)