Radhika
Radhika

Reputation: 2561

Coulmns are hidden while downloading xlsx file using axlsx gem

I am using axlsx gem for downloading xlsx files.

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.

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 :)

Upvotes: 1

Views: 731

Answers (1)

Radhika
Radhika

Reputation: 2561

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:

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

Upvotes: 1

Related Questions