Sha256: e0e440954a6b509eb065819bb4f731948dfc624bf0d1b3ecd289f03b4eb4d343

Contents?: true

Size: 1.24 KB

Versions: 38

Compression:

Stored size: 1.24 KB

Contents

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

#######################################################################
#
# An Excel::Writer::XLSX example showing how to use "rich strings", i.e.,
# strings with multiple formatting.
#
# reverse(c), February 2011, John McNamara, jmcnamara@cpan.org
# convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
#

require 'rubygems'
require 'write_xlsx'

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

worksheet.set_column('A:A', 30)

# Set some formats to use.
bold   = workbook.add_format(:bold        => 1)
italic = workbook.add_format(:italic      => 1)
red    = workbook.add_format(:color       => 'red')
blue   = workbook.add_format(:color       => 'blue')
center = workbook.add_format(:align       => 'center')
superc = workbook.add_format(:font_script => 1)

# Write some strings with multiple formats.
worksheet.write_rich_string('A1',
    'This is ', bold, 'bold', ' and this is ', italic, 'italic')

worksheet.write_rich_string('A3',
    'This is ', red, 'red', ' and this is ', blue, 'blue')

worksheet.write_rich_string('A5',
    'Some ', bold, 'bold text', ' centered', center)

worksheet.write_rich_string('A7',
    italic, 'j = k', superc, '(n-1)', center)

workbook.close

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
write_xlsx-0.69.0 examples/rich_strings.rb
write_xlsx-0.65.1 examples/rich_strings.rb
write_xlsx-0.65.0 examples/rich_strings.rb
write_xlsx-0.64.1 examples/rich_strings.rb
write_xlsx-0.64.0 examples/rich_strings.rb
write_xlsx-0.62.0 examples/rich_strings.rb
write_xlsx-0.61.0 examples/rich_strings.rb
write_xlsx-0.60.0 examples/rich_strings.rb
write_xlsx-0.59.0 examples/rich_strings.rb
write_xlsx-0.58.0 examples/rich_strings.rb
write_xlsx-0.57.0 examples/rich_strings.rb
write_xlsx-0.56.0 examples/rich_strings.rb
write_xlsx-0.55.0 examples/rich_strings.rb
write_xlsx-0.54.0 examples/rich_strings.rb
write_xlsx-0.51.0 examples/rich_strings.rb
write_xlsx-0.0.4 examples/rich_strings.rb
write_xlsx-0.0.3 examples/rich_strings.rb
write_xlsx-0.0.2 examples/rich_strings.rb