weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.28k stars 255 forks source link

Inconsistent return value for cell.fill_color #251

Closed PriyankaRPathak closed 7 years ago

PriyankaRPathak commented 7 years ago

Hi, I'm using RubyXL for my rails project. Surprisingly, sometime I received cell color as 6 characters code or 8 characters code. I already review code and it shows 6 characters should be return.

doc = RubyXL::Parser.parse('File Path') cell_1 = doc[1][1][0].fill_color

Often it returns 'f3dcdb' or 'fff3dcdb'.

I don't understand why this is the case?

weshatheleopard commented 7 years ago

I don't see anything to justify that behavior in the code. The code simply returns whatever is there in the spreadsheet. So if you can send me the file you are having trouble with, or provide exact steps to reproduce, I could research further.

PriyankaRPathak commented 7 years ago

Hi,

Thanks for prompt reply.

Attached ruby-xl-color-issue.zip. Unzip it which will show you 3 files demo.rb, demo.xlsx, demo_full_correction_manual.xlsx. I suggest you to set FILE_PATH in demo.rb before running it via console and place *.xlsx at FILE_PATH. Run the demo.rb which will display Case 3 & Case 4 with cell[3][0]'s color value as 'f3dcdb' & 'FFF3DCDB'.

This issue raise when we open RubyXL generated file manually and without even touching anything we save it then Highlighted cell will return different characters limit during RubyXL parsing.

ruby-xl-color-issue.zip

denis-adobe commented 7 years ago

I just tried your ruby script and had no differences

this was my console output:

ruby demo.rb Case 1: Open File - Highlight Empty/Invalid cell with Red Background. Case 2: Open File -> Confirm Highlighted cell has BG color - f3dcdb Row 2 -> Col 1 -> "f3dcdb" Row 3 -> Col 0 -> "f3dcdb" Case 3: Re-open Partially corrected file -> Confirm Highlighted cell still has BG color - f3dcdb Row 2 -> Col 1 -> "ffffff" Row 3 -> Col 0 -> "f3dcdb" Case 4: Manually Open generated demo_full_correction.xlsx and then save it to demo_full_correction_manual.xlsx. It will change buggy cell color from f3dcdb to fff3dcdb. Row 3 -> Col 0 -> "f3dcdb" Here is my question: Why Fill color will returns different characters ie. f3dcdb & FFF3DCDB?

I tried it multiple times but the hex code wasnt capitalized or changed once. What system spec do you use? Are your Excel files corrupt?