thinreports / thinreports-generator

A Ruby library for Thinreports
https://github.com/thinreports/thinreports
MIT License
294 stars 48 forks source link

How to change background color ? #98

Closed TranBaVinhSon closed 5 years ago

TranBaVinhSon commented 5 years ago

Does thinreports provide api to change color of background like :

page.item(:text).style(:background-color, '#000000')

In my case, I want to change background color of a row in list, for example:

    datas.each do |data|
      report.list.add_row do |row|
        row.values col1: data[0],
                   col2: data[1],
                   col3: data[2]
        row.style(:background-color, '#000000')
      end
    end

How can I do that ?

Sotatek-NgocBach commented 5 years ago

I think row.style(:fill_color, '#000000') could help

TranBaVinhSon commented 5 years ago

@Sotatek-NgocBach thanks for your help. But it didn't work. When I try row.style(:fill_color, '#000000') I got this error:

"#<NoMethodError: undefined method `style' for #<Thinreports::Core::Shape::List::SectionInterface:0x00007fb0f7f54a88>>"

And tried with row.item(:col1).style(:fill_color, '#ffffff'), still got new error:

#<Thinreports::Errors::UnknownShapeStyleName: The specified style name, 'fill_color', cannot be used. The available styles are :visible, :bold, :italic, :underline, :linethrough, :align, :valign, :color, :font_size.>
Sotatek-NgocBach commented 5 years ago

@TranBaVinhSon What version of Thinreports are you using?

TranBaVinhSon commented 5 years ago

@Sotatek-NgocBach yeah, great solution, I can change the background color 👍

Anyway, I have another question about how I can create the table in thinreports editor? currently, I create a list and have to draw vertical lines like this?

Screen Shot 2019-05-17 at 16 14 21
TranBaVinhSon commented 5 years ago

@Sotatek-NgocBach I'm not sure about version, I just clone Thinreport editor and launch Editor on development mode by yarn start.

Sotatek-NgocBach commented 5 years ago

@TranBaVinhSon You can use List and style to make it looks like a table

hidakatsuya commented 5 years ago

@TranBaVinhSon

how I can create the table in thinreports editor?

Thinreports has no feature for creating Table and currently we have no plan for it.

@Sotatek-NgocBach Thanks for your support!