renebigot / XlsxReaderWriter

XlsxReaderWriter is an Objective-C library for iPhone / iPad and Mac. It parses and writes MS Excel XLSX files.
MIT License
437 stars 121 forks source link

Opening File Crash #89

Open MMMUK1 opened 7 years ago

MMMUK1 commented 7 years ago

Hi @renebigot,

This file caused crash when opening

We experienced a crash when opening the following file attached here: XlsxReader Crash File.xlsx.zip

A recommendation is below to resolve the crash quickly.
But you may have a better solution and look forward to hearing your views:

BRAStyles.m

The crash was located at Row 182 in ...XlsxReaderWriter/XlsxReaderWriter/BRAStyles.m: } else { return self.indexedColors[[attributes[@"_indexed"] integerValue]];

this seemed to be fixed with:

if([attributes[@"_indexed"] integerValue] < self.indexedColors.count) return self.indexedColors[[attributes[@"_indexed"] integerValue]]; else return [UIColor blackColor]; }

Default Colors - an out of bounds fix

I saw your issue #4 fix about colours linked to cell comments. I think this is a similar type of issue but a different crash source when opening a *.xlsx file with certain colour attributes.

With regard to #4 :

renebigot commented on 22 Sep 2015 It seems that Excel has created a color indexed at index 81 (may be different in your case). Default indexed colors indexes should be lower than 65. No color 81 is defined by Excel in the XMLs: I don't understand why. I'm working on it. renebigot commented on 28 Sep 2015 this bug is corrected in the current version.

** We agree. And how did you fix it? My guess is that when companies ask branding/marketing companies to provide Excel templates, the branding/marketing Excel teams mess around with default color indexes so that client companies can use their default brand colours (i.e. outside of the typical default colours under 65). Do you think this could be the reason for disruption in default attributes over 65?

Regards, Michael