Search code examples
excelexport-to-excelaxlsx

Rails: Add border in axlsx


Using axlsx it is possible to add border. I added something like this

red_border = p.workbook.styles.add_style :border => { :style => :thin, :color => "FFFF0000" }

But this gives border on all sides of a cell. But I need only top and bottom border of a cell not left and right border. How can I implement that? So that my border show only top and bottom.


Solution

  • I found the solution here. Just use edge attributes with top and bottom.

    red_border = p.workbook.styles.add_style :border => { :style => :thin, :color => "FFFF0000", :edges => [:top, :bottom] }