简体   繁体   English

Randym / axlsx-gem,样式问题

[英]Randym/axlsx - gem, Styling Issue

I have been using rails randym/axlsx gem, version 2.0.1, for generating excel view in my application. 我一直在使用Rails randym / axlsx gem(版本2.0.1)在我的应用程序中生成excel视图。 I have certain issues related to the styling of the excel sheet. 我有一些与Excel工作表样式有关的问题。

This is the html file am trying to implement in excel. 这是HTML文件,试图在excel中实现。
在此处输入图片说明

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: 这是我现在生成的excel文件的示例: 在此处输入图片说明

To bring the diagonals, as mentioned in the randym/axlsx document, I tried, 如randym / axlsx文件中所述,为了使对角线对准,我尝试过,

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. 但是除了“:edges => [:left,:right,:top,:bottom,:diagonal]”中的对角线边缘外,所有其他边缘均在excel工作表中正确显示。

1. Why is the diagonal edges not working? 1.为什么对角线边缘不起作用?
2. How to align all the four texts in each portion of the diagonal as in the above image? 2.如上图所示,如何在对角线的每个部分对齐所有四个文本?

Another problem i am facing is that, I brought an image to the excel file using the below code: 我面临的另一个问题是,我使用以下代码将图像带到excel文件中:

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? 3.如何将图像放置在单元格的中央?

Please help. 请帮忙。

试试这个,可能对您有帮助-

style.add_style( border: { style: :thin, color: "000000", :alignment=>{:horizontal => :center}  } )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM