lib/axlsx/package.rb in axlsx-1.1.4 vs lib/axlsx/package.rb in axlsx-1.1.5

- old
+ new

@@ -178,19 +178,28 @@ {:entry => APP_PN, :doc => @app.to_xml_string, :schema => APP_XSD}, {:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships.to_xml_string, :schema => RELS_XSD}, {:entry => CONTENT_TYPES_PN, :doc => content_types.to_xml_string, :schema => CONTENT_TYPES_XSD}, {:entry => WORKBOOK_PN, :doc => workbook.to_xml_string, :schema => SML_XSD} ] + workbook.drawings.each do |drawing| @parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships.to_xml_string, :schema => RELS_XSD} @parts << {:entry => "xl/#{drawing.pn}", :doc => drawing.to_xml_string, :schema => DRAWING_XSD} end + workbook.tables.each do |table| @parts << {:entry => "xl/#{table.pn}", :doc => table.to_xml_string, :schema => SML_XSD} end + workbook.comments.each do|comment| + if comment.size > 0 + @parts << { :entry => "xl/#{comment.pn}", :doc => comment.to_xml_string, :schema => SML_XSD } + @parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing.to_xml_string, :schema => nil } + end + end + workbook.charts.each do |chart| @parts << {:entry => "xl/#{chart.pn}", :doc => chart.to_xml_string, :schema => DRAWING_XSD} end workbook.images.each do |image| @@ -227,21 +236,36 @@ # Appends override objects for drawings, charts, and sheets as they exist in your workbook to the default content types. # @return [ContentType] # @private def content_types c_types = base_content_types + workbook.drawings.each do |drawing| c_types << Axlsx::Override.new(:PartName => "/xl/#{drawing.pn}", :ContentType => DRAWING_CT) end + workbook.charts.each do |chart| c_types << Axlsx::Override.new(:PartName => "/xl/#{chart.pn}", :ContentType => CHART_CT) end + workbook.tables.each do |table| c_types << Axlsx::Override.new(:PartName => "/xl/#{table.pn}", :ContentType => TABLE_CT) end + + workbook.comments.each do |comment| + if comment.size > 0 + c_types << Axlsx::Override.new(:PartName => "/xl/#{comment.pn}", + :ContentType => COMMENT_CT) + end + end + + if workbook.comments.size > 0 + c_types << Axlsx::Default.new(:Extension => "vml", :ContentType => VML_DRAWING_CT) + end + workbook.worksheets.each do |sheet| c_types << Axlsx::Override.new(:PartName => "/xl/#{sheet.pn}", :ContentType => WORKSHEET_CT) end exts = workbook.images.map { |image| image.extname }