caxlsx / caxlsx_rails

A Rails plugin to provide templates for the axlsx gem
MIT License
735 stars 84 forks source link

insert_worksheet is clearing my instance variables #140

Closed AngelMDev closed 4 years ago

AngelMDev commented 4 years ago

Let's say I have an instance variable coming in from my controller called @company

Then In my .xlsx.axlsx

wb = xlsx_package.workbook
wb.insert_worksheet(1, name: 'Sheet 2') do |sheet|
  sheet.add_row([@company.name]) # <- Works fine
end

wb.insert_worksheet(0, name: 'Sheet 1') do |sheet|
  sheet.add_row([@company.name]) # <- Throws exception, @company is nil
end

add_worksheet doesn't have the same issue. Am I missing something? Also not sure if I should post that here or in the axlsx repo

straydogstudio commented 4 years ago

@AngelMDev For future reference, that would probably do better in the caxlsx repo, since it is internal to the library.