plasma-umass / DataDebug

Excel 2010/2013 add-in that automatically finds errors in spreadsheets
http://checkcell.org
GNU General Public License v2.0
48 stars 6 forks source link

CheckCell does nothing when opened on a blank worksheet #63

Open dbarowy opened 9 years ago

dbarowy commented 9 years ago

The reason is that it was silently throwing an exception when opened on blank sheets. This is because Excel does not emit a WorkbookOpen event when opened with its template workbooks, which meant that the WorkbookState object we normally create during workbook open events did not exist in the state dictionary. This caused a "key not found" exception. The fix is to check to see if our dictionary key exists, and if it doesn't, to create it on demand.

dbarowy commented 9 years ago

Fixed with e3e2630.

emeryberger commented 9 years ago

Problem persists. Reproduce by (1) opening Excel, (2) typing in a row of numbers, followed by =SUM(A1:A5), and (3) clicking on Analyze (nothing happens).

If you load the saved worksheet, it works fine.

dbarowy commented 9 years ago

It turns out that the issue really boils down to: there's a race between the plugin startup routine and the WorkbookOpen event. It appears that in Excel 2013, the blank template loads before CheckCell loads, so it never sees the WorkbookOpen event. I never observed this because in my copy of Excel 2013 because I never got around to activating my copy-- the activation screen causes the CheckCell plugin to load first on my machine.

I believe that the fix is to check if there is already an active workbook when the plugin loads. If there is, create a new WorkbookState object. If not, then CheckCell loaded first, so continue as normal.

@emeryberger: can you please try the pre-release installer?

https://github.com/plasma-umass/DataDebug/releases/tag/v1.0.5