-2146826246 in win32com.client for empty #N/A cell in Excel

Sven Boden sven.boden at gmail.com
Sun Aug 16 12:53:32 EDT 2015


Anyone know how to handle "#N/A" in Excel from win32com.client.

I'm extracting data from an Excel file using win32com.client. Everything works fine except for when the value "#N/A" is entered in excel. An empty cell. I assumed I do something as 

if ws.Cells(r, c).Value is None:
    ...

But that doesn't seem to work. When I debug the piece of code while handling #N/A in a cell the type of the cell according to win32com.client is int and the value in the cell is -2146826246. Chances are small just this number will appear in Excel, but it looks dirty to depend on that value to decide if a cell is empty. Looked around the net for a solution, but nothing came up so far.

Anyone knows how to handle a "#N/A" cell in Excel in the proper way?

Regards,
Sven



More information about the Python-list mailing list