Reputation: 6714
I'm following this tutorial to create a pdf file using prawn gem, and I found this reference documentation to generate a table.
How do I set the header row and the header titles to each column?
invoiceData = [["foo","bar"]]
pdf.table(invoiceData) do |table|
table.rows(1..3).width = 72
end
Upvotes: 10
Views: 5302
Reputation: 15515
In addition to the answer of @dogenpunk, it is also possible to set the styling of the header row:
table_data = generate_lots_of_table_data
table_data.unshift %w(id name address) # add headers
table(table_data, header: true) do
row(0).style font_style: :bold # header style
end
Upvotes: 2
Reputation: 4382
If you pass :header => true as an option it should use the first row of your array as a repeating header. From the docs:
data = [["This row should be repeated on every new page"]]
data += [["..."]] * 30
table(data, :header => true)
Upvotes: 12