From 5b6fe8c7921207d402ad46fbdc0b39d162aa7851 Mon Sep 17 00:00:00 2001 From: Hannes Wyss Date: Fri, 13 Feb 2009 12:00:39 +0100 Subject: [PATCH] Honor Row, Column, Worksheet and Workbook-formats Fixes a Bug introduced in http://scm.ywesee.com/?p=spreadsheet;a=commit;h=52755ad76fdda151564b689107ca2fbb80af3b78 and reported in http://rubyforge.org/tracker/index.php?func=detail&aid=23875&group_id=678&atid=2678 and by Joachim Schneider in http://rubyforge.org/forum/forum.php?thread_id=31056&forum_id=2920 --- lib/spreadsheet/excel/writer/worksheet.rb | 6 +++--- test/integration.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/spreadsheet/excel/writer/worksheet.rb b/lib/spreadsheet/excel/writer/worksheet.rb index 08212a3..f626ef2 100644 --- a/lib/spreadsheet/excel/writer/worksheet.rb +++ b/lib/spreadsheet/excel/writer/worksheet.rb @@ -158,7 +158,7 @@ def write_calccount write_op 0x000c, [count].pack('v') end def write_cell type, row, idx, *args - xf_idx = @workbook.xf_index @worksheet.workbook, row.formats[idx] + xf_idx = @workbook.xf_index @worksheet.workbook, row.format(idx) data = [ row.idx, # Index to row idx, # Index to column @@ -358,7 +358,7 @@ def write_eof # Write a cell with a Formula. May write an additional String record depending # on the stored result of the Formula. def write_formula row, idx - xf_idx = @workbook.xf_index @worksheet.workbook, row.formats[idx] + xf_idx = @workbook.xf_index @worksheet.workbook, row.format(idx) cell = row[idx] data1 = [ row.idx, # Index to row @@ -562,7 +562,7 @@ def write_mulblank row, idx, multiples ] # List of nc=lc-fc+1 16-bit indexes to XF records (➜ 6.115) multiples.each_with_index do |blank, cell_idx| - xf_idx = @workbook.xf_index @worksheet.workbook, row.formats[idx + cell_idx] + xf_idx = @workbook.xf_index @worksheet.workbook, row.format(idx + cell_idx) data.push xf_idx end # Index to last column (lc) diff --git a/test/integration.rb b/test/integration.rb index b506650..3a51cb5 100644 --- a/test/integration.rb +++ b/test/integration.rb @@ -580,7 +580,7 @@ def test_change_cell sheet = book.worksheet 0 assert_equal 11, sheet.row_count assert_equal 12, sheet.column_count - useds = [0,0,0,0,0,0,0,1,0,0,11] + useds = [0,0,0,0,0,0,0,0,0,0,0] unuseds = [2,2,1,1,1,2,1,11,1,2,12] sheet.each do |row| assert_equal useds.shift, row.first_used @@ -689,7 +689,7 @@ def test_change_cell__complete_sst_rewrite sheet = book.worksheet 0 assert_equal 11, sheet.row_count assert_equal 12, sheet.column_count - useds = [0,0,0,0,0,0,0,1,0,0,11] + useds = [0,0,0,0,0,0,0,0,0,0,0] unuseds = [2,2,1,1,1,2,1,11,1,2,12] sheet.each do |row| assert_equal useds.shift, row.first_used