Is it possible to change text color in same cell?

91 views
Skip to first unread message

Hiroyuki Sato

unread,
Jun 3, 2015, 6:57:11 AM6/3/15
to ax...@googlegroups.com
Hello 

I would like to highlight (change color) text in same cell.

Is it possible to change text color in same cell?

Could you tell me any example code?

Thank you for your advice.

--
Hiroyuki Sato.


Hiroyuki Sato

unread,
Jun 9, 2015, 7:33:16 AM6/9/15
to ax...@googlegroups.com

I found ``RichText#add_run("text", :color => 'FF0000')``.

Thanks.

```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, :color => 'FF0000')
  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
```




2015年6月3日水曜日 19時57分11秒 UTC+9 Hiroyuki Sato:
Reply all
Reply to author
Forward
0 new messages