Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Error parsing xlsx file created by rubyXL with font styles #25

Closed
ameliaj8 opened this Issue · 4 comments

5 participants

@ameliaj8

Writing an XLSX file:

workbook = RubyXL::Workbook.new()
worksheet = RubyXL::Worksheet.new(workbook,'Blah'')
workbook.worksheets[0] = worksheet #overwrite initial 'Sheet1' worksheet

#Make the first row 'Blah'
workbook.worksheets[0].add_cell(0,0,'Blah')
workbook.worksheets[0].change_row_bold(0,true) # text in Bold
workbook.worksheets[0].change_row_fill(0, 'BFBFBF') #sets color to grey
workbook.worksheets[0].change_row_font_color(0, '5A5A5A') #sets title in grey

#Add some content from row 1 here....

#Make row 1 bold
workbook.worksheets[0].change_row_bold(1,true)
workbook.worksheets[0].change_row_fill(1, '5A5A5A') #sets color to grey
workbook.worksheets[0].change_row_font_color(1, 'FFFFFF') #sets text white

#Write to file
workbook.write(xlsx_filename)

#Read same file
workbook = RubyXL::Parser.parse(xlsx_filename)

Error:
undefined method []' for nil:NilClass /usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.5/lib/rubyXL/parser.rb:142:inblock in fill_styles' /usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.5/lib/rubyXL/parser.rb:139:in each' /usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.5/lib/rubyXL/parser.rb:139:infill_styles' /usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.5/lib/rubyXL/parser.rb:72

@brazir
@mblake

I have a problem a lot like this. I discovered by that removing all of the calls to change_horizontal_alignment, it went away. Calling change_horizontal_alignment seemed to mess up the formatting in other cells.

@weshatheleopard

I tried, and this no longer happens on the latest version. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.