【问题标题】:How can I add an image to a table cell using the Axlsx gem?如何使用 Axlsx gem 将图像添加到表格单元格?
【发布时间】:2013-02-08 17:44:46
【问题描述】:

我正在使用 Axlsx gem 创建一个 excel 文件,我想添加一个图像。我目前能够添加图像,但它似乎以使其浮动在其他内容之上的方式添加图像。

我希望它存在于一个单元格中。这可能吗?

【问题讨论】:

  • 嗨瑞恩。您是指作为单元格的背景,还是仅限于单元格的高度/宽度?如果可以,请在 irc freenode#axlsx 上抓住我。 - 最好的随机数
  • 嗯,主要是为了让单元格调整为图像的大小。
  • 干杯伙伴,我会尽快在此处发布示例。

标签: ruby excel axlsx


【解决方案1】:

这是一个老问题,但我们永远不知道。

这个帖子里有答案:Adding image to Excel file generated by Axlsx.?

您可以使用 image.start_at 指定要从中放置图像的单元格

sheet.add_image(:image_src => img, :noSelect => true, :noMove => true,   :hyperlink=>"http://axlsx.blogspot.com") do |image|
  image.width = 7
  image.height = 6
  image.hyperlink.tooltip = "Labeled Link"
  image.start_at 2, 2
end

HTH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-24
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    • 2011-09-10
    • 2017-08-02
    相关资源
    最近更新 更多