我收到以下代码的以下错误:undefined method 'rowspan=' for #<Prawn::Table::Cell::Text:0x9477540>
table [
[{content: "<b>control</b>", rowspan: 2},
{content: "time", colspan: 2},
"order",
{content: "count", colspan: 6}]
], cell_style: {size: 10, inline_format: true}
我跟着虾手册,看不出我做错了什么。我正在使用虾0.12.0。
答案 0 :(得分:0)
根据Prawn google小组的说法,colspan和rowspan直到稍后发布才被引入。 https://groups.google.com/forum/#!searchin/prawn-ruby/rowspan/prawn-ruby/G-QHFUZheMI/3a4pNnLur0EJ
从github更新到最新的master gem为我工作:
git clone https://github.com/prawnpdf/prawn.git
创建一个目录来测试手册示例 运行bundle init以在该目录中创建Gemfile并添加此行
gem 'prawn', :path=>'/path/to/your/local/prawn/git/clone/dir'
从手册中创建span_example.rb文件,并将其设置为使用Bundler Gemfile,如下所示:
require 'rubygems'
require 'bundler/setup'
Bundler.require
pdf = Prawn::Document.generate('span_example.pdf') do
table([
["A", {content: "2x1", colspan: 2}, "B"],
[{content: "1x2", rowspan: 2}, "C", "D", "E"],
[{content: "2x2", colspan: 2, :rowspan => 2}, "F"],
["G", "H"]
])
end
然后运行
bundle install
ruby span_example.rb
open span_example.pdf
中提琴!