Sha256: 028bc05b14f697318c4d8ec370cebf0333ae961ef011371accf9675ea225754e

Contents?: true

Size: 1.99 KB

Versions: 3

Compression:

Stored size: 1.99 KB

Contents

module Asposecellsjava
  module PageBreaks
    def initialize()
        @data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
        
        # Instantiating a Workbook object
        workbook = Rjb::import('com.aspose.cells.Workbook').new
        
        # Adding Page Breaks
        add_page_breaks(workbook)

        # Clearing All Page Breaks 
        clear_all_page_breaks(workbook)

        # Removing Specific Page Break
        remove_page_break(workbook)
    end

    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    

    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  

    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  
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asposecellsjava-0.0.3 lib/asposecellsjava/pagebreaks.rb
asposecellsjava-0.0.2 lib/asposecellsjava/pagebreaks.rb
asposecellsjava-0.0.1 lib/asposecellsjava/pagebreaks.rb