How to format whole column for an excel using axlsx (ruby)
NickName:ela Ask DateTime:2015-06-11T08:14:27

How to format whole column for an excel using axlsx (ruby)

I am pretty new to ruby and trying to format all columns generated to text for the excel file. I have got a function as below

def writeXlsx(columnNames, templateName)
        @xlsx = Axlsx::Package.new              # create xlsx doc
        @xlsx.use_autowidth = true
        @xlsxSheet = @xlsx.workbook.add_worksheet(:name => templateName)
        @unlocked = @xlsx.workbook.styles.add_style(:locked => false)       
        @xlsxSheet.col_style(0,@unlocked)
        @xlsxSheet.add_row columnNames, :types => string


        @xlsx.serialize(File.join(@outputFolder, "#{templateName}.xlsx"))

    end

this errors out saying col_style undefined method. Can you please tell me what I am doing wrong? -ela

Copyright Notice:Content Author:「ela」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769487/how-to-format-whole-column-for-an-excel-using-axlsx-ruby

More about “How to format whole column for an excel using axlsx (ruby)” related questions

How to format whole column for an excel using axlsx (ruby)

I am pretty new to ruby and trying to format all columns generated to text for the excel file. I have got a function as below def writeXlsx(columnNames, templateName) @xlsx = Axlsx::Packag...

Show Detail

Ruby Axlsx Gem Unlocking style on whole column

Using Ruby with the gem axlsx I've been trying to figure out how to set a style for an entire column and I haven't yet found it. The only way I've been able to do this is in a loop, setting each ce...

Show Detail

How to set auto width of Excel columns using axlsx gem in Ruby on rails

Is there a way to set the column width to adjust based on the text length for all the columns in an excel (that is generated using the axlsx gem in Ruby on rails)? Please help!

Show Detail

Formatting a cell as Text using the axlsx spreadsheet ruby gem?

I'm using the axlsx ruby gem to create Excel-compatible .xlsx files. I can't figure out how to override the cell type that is generated by it's automatic type detection. For Active Record model

Show Detail

Create Excel file in Ruby on Rails with Axlsx

I try to create Excel files with the gem "axlsx". But i work for the first time with this gem and i try one Test. I make one link_to to an controller action. There is no Error, but i didnt find a

Show Detail

Rails 4, axlsx, and acts_as_xlsx: How to make each column its own sheet?

Gems https://github.com/randym/axlsx https://github.com/randym/acts_as_xlsx Tutorial http://axlsx.blog.randym.net/2011/12/axlsx-making-excel-reports-with-ruby-on.html In the tutorial the Post ...

Show Detail

axlsx / axlsx_rails dependancy / conflict issues

I am trying to add simple Excel file downloads to my Rails app with https://github.com/randym/axlsx and https://github.com/straydogstudio/axlsx_rails but I can't seem to get the dependancies sorted...

Show Detail

axlsx_rails gem: how to display leading zeros in Excel

I am using rails gem 'axlsx_rails' to generate Excel sheets. I have strings in my database with leading zeros. But, by default, the column is coming with "General" format. So it does not display the

Show Detail

Issue with opening the generated file in MS Excel using axlsx_rails

I am using axlsx_rails in my Rails project to generate an excel file with validations and dropdowns. After generating the File, I tried to open the file in MS Excel and it said that it needs to rep...

Show Detail

Date format is recognised as custom in excel and not as date, where the excel sheet is generated using ruby on rails framework

I am using Axlsx gem in ruby-on-rails framework to generate a spreadsheet in .xlsx format, the spreadsheet gets generated but it detects the date field only in the Linux distros, in windows if I do...

Show Detail