lib/spreadsheet/excel/writer/worksheet.rb in spreadsheet-0.8.9 vs lib/spreadsheet/excel/writer/worksheet.rb in spreadsheet-0.9.0
- old
+ new
@@ -311,10 +311,12 @@
# Necessary for outline (grouping) and hiding functions
# but these below are not necessary to run
# if [Row|Column]#hidden? = false and [Row|Column]#outline_level == 0
write_merged_cells
+ write_pagesetup
+ write_margins
write_colinfos
write_guts
@io.write reader.read(endpos - lastpos)
end
@@ -496,10 +498,12 @@
write_merged_cells
# ○ LABELRANGES ➜ 5.64
# ○ PHONETIC ➜ 5.77
# ○ Conditional Formatting Table ➜ 4.12
# ○ Hyperlink Table ➜ 4.13
+ write_pagesetup
+ write_margins
write_hyperlink_table
# ○ Data Validity Table ➜ 4.14
# ○ SHEETLAYOUT ➜ 5.96 (BIFF8X only)
# ○ SHEETPROTECTION Additional protection, ➜ 5.98 (BIFF8X only)
# ○ RANGEPROTECTION Additional protection, ➜ 5.84 (BIFF8X only)
@@ -855,9 +859,30 @@
merge_cells = @worksheet.merged_cells.dup
while (window = merge_cells.slice!(0...1027)).any?
count = window.size
data = ([count] + window.flatten).pack('v2v*')
write_op opcode(:mergedcells), data
+ end
+ end
+
+ def write_pagesetup
+ return unless @worksheet.pagesetup
+ data = @worksheet.pagesetup[:orig_data].dup
+ if @worksheet.pagesetup[:orientation]
+ data[5] = @worksheet.pagesetup[:orientation] == :landscape ? 0 : 2
+ end
+
+ if @worksheet.pagesetup[:adjust_to]
+ data[1] = @worksheet.pagesetup[:adjust_to]
+ end
+
+ write_op opcode(:pagesetup), data.pack(binfmt(:pagesetup))
+ end
+
+ def write_margins
+ @worksheet.margins.each do |key, value|
+ next unless [:left, :top, :right, :bottom].include?(key)
+ write_op opcode(:"#{key}margin"), [value].pack(binfmt(:margin))
end
end
def write_proctection
return unless @worksheet.protected?