Patches: Browse | Submit New | Admin

[#27936] Fixed row not outputting in batch of 32

Date:
2010-03-05 20:37
Priority:
3
Submitted By:
Chong Kim (chongkim)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Fixed row not outputting in batch of 32

Detailed description
This is in reference to bug [#27722] "File error: data may have been lost" loading
into Excel 2007

  http://rubyforge.org/tracker/index.php?func=detail&aid=27722&group_id=678&atid=2677

This is where you
  1. add "test" to A1
  2. save file
  3. load file
  4. add "test" to A2
  5. save file

The resulting file will generate an error message saying that you may have lost data, even though the file seems to
load up properly without any data loss.

What is happening is that it loads the row (A1) from the file.  A new row (A2) is inserted into the spreadsheet.  When
it writes to the file, the row is outputted in a batch of up to 32 rows, which includes the A1 along with the new row
A2.  Then it continues from where it left off from the original file, which includes the A1 row again.  The output looks
something like this:

   row1 (from file)
   row2 (new row)
   labelsst of row1 (col 1)
   labelsst of row2 (col 1)
   row1 (from file)
   labelsst of row1 (col 1)

Excel is probably triggering the error when it sees that the row info is not in a batch of 32.

In lib/spreadsheet/excel/writer/worksheet.rb:249, you have:

      @worksheet.offsets.each do |key, pair|
        if changes.include?(key) \
          || (sst_status == :complete_update && key.is_a?(Integer))
          offsets.store pair, key
      end

The sst_status == :complete_update is preventing the non-changed rows to be processed and thus it is outputted after
it the row blocks, thus duplicating the output of those rows.

I removed the sst_status check and it seems to be working now.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
worksheet.patch patch file for lib/spreadsheet/excel/writer/worksheet.rb Download

Changes:

Field Old Value Date By
File Added4882: worksheet.patch2010-03-05 20:37chongkim