45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/xlsx/workbook.rb', line 45
def write(filename=nil)
@strings_count = 0
@strings = []
@strings_idx = {}
filename ||= @filename
File.unlink(filename) if File.exists?(filename)
Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zipfile|
zipfile.get_output_stream("[Content_Types].xml") { |f| write_content_types(f) }
zipfile.get_output_stream("_rels/.rels") { |f| write_root_rels(f) }
zipfile.get_output_stream("docProps/app.xml") { |f| write_app_properties(f) }
zipfile.get_output_stream("docProps/core.xml") { |f| write_core_properties(f) }
zipfile.get_output_stream("xl/_rels/workbook.xml.rels") { |f| write_workbook_rels(f) }
zipfile.get_output_stream("xl/workbook.xml") { |f| write_workbook(f) }
zipfile.get_output_stream("xl/styles.xml") { |f| write_styles(f) }
0.upto(@sheets.size - 1) do |sheet_no|
zipfile.get_output_stream("xl/worksheets/sheet#{sheet_no + 1}.xml") { |f| write_worksheet(@sheets[sheet_no], f) }
end
zipfile.get_output_stream("xl/sharedStrings.xml") { |f| write_shared_strings(f) }
end
@strings_count = nil
@strings = nil
@strings_idx = nil
true
end
|