0

I have been using rails randym/axlsx gem, version 2.0.1, for generating excel view in my application. I have certain issues related to the styling of the excel sheet.

This is the html file am trying to implement in excel.
enter image description here

So far i have been successful in displaying all the contents correctly towards all the four sides. But am stuck at the Cross section in the middle.

This is the sample of excel file i have generated as if now: enter image description here

To bring the diagonals, as mentioned in the randym/axlsx document, I tried,

style.add_style( border: { style: :thin, color: "000000", :edges => [:left, :right, :top, :bottom, :diagonal]   } )

But except the diagonal edges in ":edges => [:left, :right, :top, :bottom, :diagonal]", all other edges where displayed correctly in the excel sheet.

1. Why is the diagonal edges not working?
2. How to align all the four texts in each portion of the diagonal as in the above image?

Another problem i am facing is that, I brought an image to the excel file using the below code:

sheet.add_image(:image_src => img) do |image|
    image.width = 20
    image.height = 20
    image.start_at column, row
end

The image is positioned at the top left corner of the cell.

3. How do i position the image at the center of the cell?

Please help.

Toby Joy
  • 21
  • 7

1 Answers1

0

Try this, it may be help you-

style.add_style( border: { style: :thin, color: "000000", :alignment=>{:horizontal => :center}  } )
VijayGupta
  • 637
  • 3
  • 11
  • Sorry I didn't understand what you meant by border alignment, this code didn't work for me as well. – Toby Joy Feb 09 '17 at 09:59