diff options
| author | Jurriaan Pruis <[email protected]> | 2014-03-01 21:17:25 +0100 |
|---|---|---|
| committer | Jurriaan Pruis <[email protected]> | 2014-03-01 21:17:25 +0100 |
| commit | 043dc9ad9a807c9011821840cd3f43ca71456c2e (patch) | |
| tree | 6396b045e3fc3302a53d82dbcbcff408efd1662e /examples | |
| parent | 852586d08d757204f7b2ad424e273518ff17892c (diff) | |
| download | caxlsx-043dc9ad9a807c9011821840cd3f43ca71456c2e.tar.gz caxlsx-043dc9ad9a807c9011821840cd3f43ca71456c2e.zip | |
Implemented RichText (multiple text runs)
and added multiline autowidth for both RichText and normal strings
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/example.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/examples/example.rb b/examples/example.rb index d8519a26..116ce730 100755 --- a/examples/example.rb +++ b/examples/example.rb @@ -49,6 +49,8 @@ examples << :shared_strings examples << :no_autowidth examples << :cached_formula examples << :page_breaks +examples << :rich_text + p = Axlsx::Package.new wb = p.workbook #``` @@ -794,8 +796,7 @@ if examples.include? :no_autowidth end #``` - - +#```ruby if examples.include? :cached_formula p = Axlsx::Package.new p.use_shared_strings = true @@ -805,4 +806,23 @@ if examples.include? :cached_formula end p.serialize 'cached_formula.xlsx' end +#``` +#```ruby +if examples.include? :rich_text + p = Axlsx::Package.new + p.use_shared_strings = true + wb = p.workbook + wrap_text = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}} ) + rt = Axlsx::RichText.new + rt.add_run('I\'m bold, ', :b => true) + rt.add_run('I\'m italic, ', :i => true) + rt.add_run('I\'m strike' + "\n", :strike => true) + rt.add_run('I\'m bold, italic and strike' + "\n", :b => true, :i => true, :strike => true) + rt.add_run('I\'m style-less :D') + wb.add_worksheet(:name => "RichText") do | sheet | + sheet.add_row [rt], :style => wrap_text + end + p.serialize 'rich_text.xlsx' +end +#```
\ No newline at end of file |
