【问题标题】:rails prawn undefined method rowspanrails prawn 未定义的方法 rowspan
【发布时间】:2013-08-21 13:03:12
【问题描述】:

我收到以下代码的以下错误: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。

【问题讨论】:

    标签: ruby-on-rails prawn


    【解决方案1】:

    根据 Prawn google 小组的说法,colspan 和 rowspan 直到以后的版本才引入。 https://groups.google.com/forum/#!searchin/prawn-ruby/rowspan/prawn-ruby/G-QHFUZheMI/3a4pNnLur0EJ

    从 github 更新到最新的 master gem 对我有用:

    git 克隆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
    

    维奥拉!

    【讨论】:

      猜你喜欢
      • 2014-08-18
      • 2015-05-06
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 2014-04-04
      • 2013-02-05
      • 1970-01-01
      • 2013-08-30
      相关资源
      最近更新 更多