lib/write_xlsx/workbook.rb in write_xlsx-0.72.3.beta1 vs lib/write_xlsx/workbook.rb in write_xlsx-0.73.0

- old
+ new

@@ -43,11 +43,10 @@ attr_reader :worksheets, :charts, :drawings # :nodoc: attr_reader :named_ranges # :nodoc: attr_reader :doc_properties # :nodoc: attr_reader :image_types, :images # :nodoc: attr_reader :shared_strings # :nodoc: - attr_accessor :table_count # :nodoc: attr_reader :vba_project # :nodoc: # # A new Excel workbook is created using the +new+ constructor # which accepts either a filename or an IO object as a parameter. # The following example creates a new Excel file based on a filename: @@ -1208,10 +1207,13 @@ # Prepare the drawings, charts and images. prepare_drawings # Add cached data to charts. add_chart_data + # Prepare the worksheet tables. + prepare_tables + # Package the workbook. packager = Package::Packager.new(self) packager.set_package_dir(@tempdir) packager.create_package @@ -1495,10 +1497,21 @@ end add_font_format_for_cell_comments if num_comment_files > 0 end + # + # Set the table ids for the worksheet tables. + # + def prepare_tables + table_id = 0 + + sheets.each do |sheet| + table_id += sheet.prepare_tables(table_id + 1) + end + end + def add_font_format_for_cell_comments format = Format.new( @formats, :font => 'Tahoma', :size => 8, @@ -1664,20 +1677,16 @@ sheet.charts.each_with_index do |chart, index| chart_ref_id += 1 sheet.prepare_chart(index, chart_ref_id, drawing_id) end - (0 .. image_count - 1).each do |index| - filename = sheet.images[index][2] - - image_id, type, width, height, name = get_image_properties(filename) - + sheet.images.each_with_index do |image, index| + image_id, type, width, height, name = get_image_properties(image[2]) image_ref_id += 1 - sheet.prepare_image(index, image_ref_id, drawing_id, width, height, name, type) end - (0..shape_count - 1).each do |index| + sheet.shapes.each_with_index do |shape, index| sheet.prepare_shape(index, drawing_id) end drawing = sheet.drawing @drawings << drawing