Sha256: 25f05ef9b02d8c3d7daded7860245bac7a363a1e8514d26f7ab17065a657de7a

Contents?: true

Size: 852 Bytes

Versions: 7

Compression:

Stored size: 852 Bytes

Contents

#!/usr/bin/env ruby

#######################################################################
#
# An example of adding a worksheet watermark image using the WriteXLSX
# rubygem. This is based on the method of putting an image in the worksheet
# header as suggested in the Microsoft documentation:
# https://support.microsoft.com/en-us/office/add-a-watermark-in-excel-a372182a-d733-484e-825c-18ddf3edf009
#
# Copyright 2000-2023, John McNamara, jmcnamara@cpan.org
# convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
#

require 'write_xlsx'

workbook  = WriteXLSX.new('watermark.xlsx')
worksheet = workbook.add_worksheet

# Set a worksheet header with the watermark image.
dirname = File.dirname(File.expand_path(__FILE__))
worksheet.set_header(
  '&C&C&[Picture]', nil,
  { image_center: File.join(dirname, 'watermark.png') }
)

workbook.close

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
write_xlsx-1.12.1 examples/watermark.rb
write_xlsx-1.12.0 examples/watermark.rb
write_xlsx-1.11.2 examples/watermark.rb
write_xlsx-1.11.1 examples/watermark.rb
write_xlsx-1.11.0 examples/watermark.rb
write_xlsx-1.10.2 examples/watermark.rb
write_xlsx-1.10.1 examples/watermark.rb