Method: Spreadsheet::Excel::Writer::Workbook#complete_sst_update?

Defined in:
lib/spreadsheet/excel/writer/workbook.rb

#complete_sst_update?(workbook) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/spreadsheet/excel/writer/workbook.rb', line 72

def complete_sst_update? workbook
  stored = workbook.sst.collect do |entry| entry.content end
  current = worksheets(workbook).inject [] do |memo, worksheet|
    memo.concat worksheet.strings
  end
  total = current.size
  current.uniq!
  current.delete ''
  if (stored - current).empty? && !stored.empty?
    ## if all previously stored strings are still needed, we don't have to
    #  rewrite all cells because the sst-index of such string does not change.
    additions = current - stored
    [:partial_update, total, stored + additions]
  else
    [:complete_update, total, current]
  end
end