【问题标题】:Table cell border表格单元格边框
【发布时间】:2009-12-07 13:42:29
【问题描述】:

这是我需要生成的 2x2 表:

r1c1  r1c2
r2c1  r2c1
      ----

换句话说,我应该打印右下角单元格的底部边框。这是我的代码:

show.pdf.虾

#This is a two dimensional array:
my_array = [["r1c1","r1c2"],["r2c1",Prawn::Table::Cell.new(:text => "r2c2", :border_width => 1 , :borders => :bottom)]]

#Table
pdf.table my_array, :border_width => 0

好吧,有了这段代码,我就有了一个没有边框的 2x2 表格!

有人有小费吗?

【问题讨论】:

  • 你需要添加一个 Prawn::Document 对象来渲染吗?我在文档中注意到以下内容: 创建一个新的单元格对象。通常通过 Document#cell 间接使用 在下面列出的可用选项中,必须提供 :point、:width 和 :text。如果您没有使用 Document#cell 快捷方式,则还必须提供 :document。

标签: ruby-on-rails pdf ruby-on-rails-plugins prawn prawnto


【解决方案1】:

这里有一个更广为人知的解决方案:

#This is a two dimensional array:
my_array = [["r1c1","r1c2"],["r2c1",Prawn::Table::Cell.new(:text => "r2c2", :border_width => 1 , :borders => [:bottom])]]

#Table
pdf.table my_array, 
#:headers => ["h1","h2"],
:border_style => :underline_header

省略 headers => ["h1","h2"] 可以避免带下划线的标题。

【讨论】:

    猜你喜欢
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多