Sha256: ad92cec466fb9985bf2ec89f5872f74367c8b5dc0f61af3001b21beedbad2ca4

Contents?: true

Size: 1.42 KB

Versions: 33

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/ruby -w
# -*- coding: utf-8 -*-

###############################################################################
#
# Example of how to use the format copying method with WriteExcel #
# reverse('©'), March 2001, John McNamara, jmcnamara@cpan.org
#
# original written in Perl by John McNamara
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#
require 'rubygems'
require 'writeexcel'

# Create workbook1
workbook1       = WriteExcel.new("workbook1.xls")
worksheet1      = workbook1.add_worksheet
format1a        = workbook1.add_format
format1b        = workbook1.add_format

# Create workbook2
workbook2       = WriteExcel.new("workbook2.xls")
worksheet2      = workbook2.add_worksheet
format2a        = workbook2.add_format
format2b        = workbook2.add_format

# Create a global format object that isn't tied to a workbook
global_format   = Format.new

# Set the formatting
global_format.set_color('blue')
global_format.set_bold
global_format.set_italic

# Create another example format
format1b.set_color('red')

# Copy the global format properties to the worksheet formats
format1a.copy(global_format)
format2a.copy(global_format)

# Copy a format from worksheet1 to worksheet2
format2b.copy(format1b)

# Write some output
worksheet1.write(0, 0, "Ciao", format1a)
worksheet1.write(1, 0, "Ciao", format1b)

worksheet2.write(0, 0, "Hello", format2a)
worksheet2.write(1, 0, "Hello", format2b)
workbook1.close
workbook2.close

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
writeexcel-1.0.4 examples/copyformat.rb
writeexcel-1.0.3 examples/copyformat.rb
writeexcel-1.0.2 examples/copyformat.rb
writeexcel-1.0.1 examples/copyformat.rb
writeexcel-1.0.0 examples/copyformat.rb
writeexcel-0.6.19 examples/copyformat.rb
writeexcel-0.6.18 examples/copyformat.rb
writeexcel-0.6.17 examples/copyformat.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.16/examples/copyformat.rb
writeexcel-0.6.16 examples/copyformat.rb
writeexcel-0.6.15 examples/copyformat.rb
writeexcel-0.6.14 examples/copyformat.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/copyformat.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/copyformat.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/copyformat.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/copyformat.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/copyformat.rb
writeexcel-0.6.13 examples/copyformat.rb
ricardoo27-writeexcel-0.6.12.2 examples/copyformat.rb
ricardoo27-writeexcel-0.6.12.1 examples/copyformat.rb