【问题标题】:How to put a header and footer in Rails with gem htmltoword?如何使用 gem htmltoword 在 Rails 中放置页眉和页脚?
【发布时间】:2017-01-26 16:55:12
【问题描述】:

我已阅读 gem 的文档,但没有看到放置页眉或页脚。

这是我的第一个代码:

format.docx {
  render docx: "path_to/file.docx",
  filename: "name_file-#{Time.now.strftime('%d-%m-%Y')}"
}

还有我的“path_to/file.docx.haml”

%html
  %head
  %body
    %header
      [..]
    %content
      %table[..]
      %h1 [..]
      %p [..]
    %footer
      %p
      %ul
        %li
      [..]

而我的另一个代码是:

format.docx {
  render docx: "path_to/file.docx",
  filename: "Proforma-#{Time.now.strftime('%d-%m-%Y')}",
  header: { 
    :content => render_to_string({ template: 'path_to/header' })
  },
  footer: { 
    :content => render_to_string({ template: 'path_to/footer' })
  }
}

而我的"path_to/file.docx.haml"只有%content标签。

然后我有其他模板:"path_to/header.haml""path_to/footer.haml"

但是没有一个对我有用。 如何正确生成带有页眉和页脚的单词?

【问题讨论】:

    标签: html ruby-on-rails ruby ms-word


    【解决方案1】:

    此 gem 当前不支持此功能(页眉和页脚均不支持)。看到这个帖子here

    【讨论】:

    • 什么 gem 推荐我生成一个词?
    猜你喜欢
    • 1970-01-01
    • 2019-07-27
    • 2020-04-26
    • 2023-01-12
    • 2012-03-11
    • 2011-06-26
    • 1970-01-01
    • 2016-05-31
    • 2019-09-15
    相关资源
    最近更新 更多