dimanche 28 juin 2015

Rowspan in prawn-table gives a "Table's width was set too small to contain its contents" error

Admittedly I am still getting the hang of Prawn-table, or even Ruby for that matter. What I am basically trying to do is expand a single cell of a table through the use of colspan and rowspan to hold a sub-table.

While i have got the colspan to work, including rowspan throws up the error specified in the title of this question. What puzzles me is that rowspan should have nothing to do with the width, contrary to what is suggested by the error. Is that not so ?

Any help extended in helping me sort out this error and getting my table format right would be highly appreciated. Thanks in advance for taking some time out to solve this.


Here's the code:

 marks_tb = make_table marks do 
                columns(0).width = 60
                columns(1).width = 210
                columns(2).width = 30
                columns(3).width = 36
                columns(4).width = 36
                columns(5).width = 40
                columns(6).width = 40
                columns(7).width = 35
                columns(8).width = 35
            end 

data = [
        ["","","","Int","Ext","Total", "","",""], 
        [{content: marks_tb,colspan: 9, rowspan: 5}]]

table data, {:position => :center,:cell_style => {border_width: 1,inline_format: true, size: 10, height: 20}}  do
        self.column_widths= {0 => 60,1 => 210,2 => 30,3 => 36, 4 => 36,5 => 40, 6 => 40,7 => 35, 8 => 35}
        row(0).font_style = :bold           
        columns(2..8).align = :center
        #row(3).height = 5
    end

enter image description here

Aucun commentaire:

Enregistrer un commentaire