当使用axlsx gem下载xlsx文件时,可以隐藏库仑。

时间:2023-02-05 09:56:35

I am using axlsx gem for downloading xlsx files.

我正在使用axlsx gem下载xlsx文件。

I am able to view all columns in the xlsx sheet when I view it using google sheets. But when I open the same file on a windows machine, only the first column is displayed rest all the columns are hidden. When I change the setting of sheet to display all cells, only then I can view all columns.

我可以在使用谷歌表查看xlsx表中的所有列时查看它。但是,当我在windows机器上打开相同的文件时,只有第一列显示,其余所有列都是隐藏的。当我改变表格的设置来显示所有的单元格时,只有这样我才能查看所有的列。

There is no explicit visibility attribute that I have added in my code.

我在代码中没有添加明确的可见性属性。

I then tried the following code snippet:

然后,我尝试了以下代码片段:

for index in (0..99) do
  sheet.column_info[index].hidden = false
end

But the issue still persists on windows. Can anyone please suggest any solution or a possible solution for this issue? Thanks in advance :)

但这个问题在windows上依然存在。对于这个问题,谁能提出解决方案或可能的解决方案吗?提前谢谢:)

1 个解决方案

#1


1  

I found the issue. The issue was I was setting the width of just the first column as follows:

我发现这个问题。问题是我把第一列的宽度设为

sheet.column_widths 30

So in google sheets the first column was displayed with the width 30 and other columns were displayed as columns with default width. But the same was not displayed in windows. In windows columns were hiding because it took width of column as nil. So added the following lines of code to set width of columns:

在谷歌表中,第一列显示宽度为30,其他列显示为默认宽度的列。但在windows中没有显示相同的内容。在windows中,列是隐藏的,因为它将列的宽度作为nil。因此,添加以下代码行来设置列的宽度:

for index in (1..99) do
   sheet.column_info[index].width = 12
end

#1


1  

I found the issue. The issue was I was setting the width of just the first column as follows:

我发现这个问题。问题是我把第一列的宽度设为

sheet.column_widths 30

So in google sheets the first column was displayed with the width 30 and other columns were displayed as columns with default width. But the same was not displayed in windows. In windows columns were hiding because it took width of column as nil. So added the following lines of code to set width of columns:

在谷歌表中,第一列显示宽度为30,其他列显示为默认宽度的列。但在windows中没有显示相同的内容。在windows中,列是隐藏的,因为它将列的宽度作为nil。因此,添加以下代码行来设置列的宽度:

for index in (1..99) do
   sheet.column_info[index].width = 12
end