ruby on rails - Writing the xlsx file using RubyXL taking very long time with large number of cells -
i using rubyxl gem in rails application generate workbook 4-5 sheets.we generating excel large number of cells(more 5000(146*26)). takes more 20 minutes write file , consume lot of memory. 1 of sheet having dynamic data has styles border ground color, font color, bold text etc.i using code snippet.
workbook = rubyxl::workbook.new() sheet = workbook.worksheets[0] cell = sheet.add_cell(row, col, text) cell.change_fill('#fff') cell.change_font_color('#000') cell.change_font_bold(true)
i tried reduce time removing style borders reduce time in writing still taking long time. i've removed remaining styling mentioned above. after taking 1 minute approx.
can please suggest me way apply styling cells take less time , not affect performance.
i happy answer question/query regarding or if miss anything.
you can change columns , rows in whole instead of cell per cell. lot faster. suppose there glitch in feature because column width after change set 0 not visible, can reset width after operation.
sheet.change_column_fill(0, '0ba500') sheet.change_column_font_color(1, '0ba53d') sheet.change_column_width(0 ,10) sheet.change_column_width(1 ,10)
Comments
Post a Comment