3

Axlsxを使用してExcelに画像を添付しています。

セルの中央に画像を移動する方法はありませんでしょうか?

以下のプログラムを参考にして作成しています。
https://stackoverflow.com/questions/10714193/adding-image-to-excel-file-generated-by-axlsx

wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
  img = File.expand_path('../image1.jpeg', __FILE__)
  # specifying the :hyperlink option will add a hyper link to your image.
  # @note - Numbers does not support this part of the specification.
  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
end
1
  • 特定のセルの中心に、画像の中心を、合わせたいということでしょうか。 ドキュメントには「If you need finer granularity in positioning use graphic_frame.anchor.from.colOff / rowOff.」とあって、確かに、colOff/rowOff使えばなんとかなりそうですが。どうやってアクセスしたものか……。ちょっと試す環境が今ないので確認できません。 2015年5月11日 11:30

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。