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

Sven Boden sven.boden at gmail.com
Sun Aug 16 13:38:57 EDT 2015


On Sun, Aug 16, 2015 at 7:27 PM, Albert-Jan Roskam <sjeik_appie at hotmail.com>
wrote:

>
>
>
> > Date: Sun, 16 Aug 2015 09:53:32 -0700
> > Subject: -2146826246 in win32com.client for empty #N/A cell in Excel
> > From: sven.boden at gmail.com
> > To: python-list at python.org
> >
> >
> > 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
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>
> Hello,
>
> Does that number happen to be -1 * sys.maxint?
>
> Regards,
> Albert-Jan
>
>
> On python 3.x sys.maxint is gone... sys.maxsize is a lot larger on Windows
64bit (same laptop I run the code on).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150816/4baade37/attachment.html>


More information about the Python-list mailing list