xlsgrid - no Excel

Hi Andrea,

I can't find a clean way to check for existence of Excel on a system, but changing around line 497 in lib.agw.xlsgrid.py to this:

     try:
         workbook = Excel(filename, sheetname)
     except:
         return comments, texts

Unless you know/find a better way maybe put this in there and change the text you show on top of the demo.

Does the trick and I also found my problem that it didn't find the Excel file. There is a change current work dir in the demoscreencapture.py which caused the problem.

Werner

Hi Werner,

···

On Tue, Mar 20, 2012 at 1:39 PM, werner wbruhin@free.fr wrote:

Hi Andrea,

I can’t find a clean way to check for existence of Excel on a system, but changing around line 497 in lib.agw.xlsgrid.py to this:

try:

    workbook = Excel(filename, sheetname)

except:

    return comments, texts

Unless you know/find a better way maybe put this in there and change the text you show on top of the demo.

Does the trick and I also found my problem that it didn’t find the Excel file. There is a change current work dir in the demoscreencapture.py which caused the problem.

Werner

I think you can check the Registry for Excel, but that might be pretty hacky.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi Mike,

···

On 20/03/2012 19:47, Mike Driscoll wrote:

Hi Werner,

On Tue, Mar 20, 2012 at 1:39 PM, werner wbruhin@free.fr > wrote:

Hi Andrea,

      I can't find a clean way to check for existence of Excel on a

system, but changing around line 497 in lib.agw.xlsgrid.py to this:

         try:

             workbook = Excel(filename, sheetname)

         except:

             return comments, texts



      Unless you know/find a better way maybe put this in there and

change the text you show on top of the demo.

      Does the trick and I also found my problem that it didn't find

the Excel file. There is a change current work dir in the
demoscreencapture.py which caused the problem.

          Werner
      I think you can check the Registry for Excel, but that

might be pretty hacky.

Didn't think about that route, looked in Mark Hammond's book but

didn’t find anything obvious.

Andrea just applied something, haven't looked how he did it (yet)

but it does the trick for the screen capture stuff.

Werner

I was thinking of the _winreg module, which is actually part of Python. Looks like there’s “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel”, which you could check the existence of and if it doesn’t exist, than Excel isn’t installed. Sadly, the 11.0 signifies Office 2003, so you’d probably have to run some kind of spidering operation on "“HKEY_CURRENT_USER\Software\Microsoft\Office” to dig through the subkeys to find the appropriate Excel. Anyway, if Andrea fixed it, than don’t worry about it.

···

On Tue, Mar 20, 2012 at 2:16 PM, werner wbruhin@free.fr wrote:

Hi Mike,

On 20/03/2012 19:47, Mike Driscoll wrote:

Hi Werner,

On Tue, Mar 20, 2012 at 1:39 PM, werner wbruhin@free.fr > > wrote:

Hi Andrea,

      I can't find a clean way to check for existence of Excel on a

system, but changing around line 497 in lib.agw.xlsgrid.py to this:

         try:

             workbook = Excel(filename, sheetname)

         except:

             return comments, texts



      Unless you know/find a better way maybe put this in there and

change the text you show on top of the demo.

      Does the trick and I also found my problem that it didn't find

the Excel file. There is a change current work dir in the
demoscreencapture.py which caused the problem.

          Werner
      I think you can check the Registry for Excel, but that

might be pretty hacky.

Didn't think about that route, looked in Mark Hammond's book but

didn’t find anything obvious.

Andrea just applied something, haven't looked how he did it (yet)

but it does the trick for the screen capture stuff.

Werner


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi Werner,

Hi Mike,

Hi Werner,

Hi Andrea,

I can't find a clean way to check for existence of Excel on a system, but
changing around line 497 in lib.agw.xlsgrid.py to this:

try:
workbook = Excel(filename, sheetname)
except:
return comments, texts

Unless you know/find a better way maybe put this in there and change the
text you show on top of the demo.

Does the trick and I also found my problem that it didn't find the Excel
file. There is a change current work dir in the demoscreencapture.py which
caused the problem.

Werner

I think you can check the Registry for Excel, but that might be pretty
hacky.

Didn't think about that route, looked in Mark Hammond's book but didn't find
anything obvious.

Andrea just applied something, haven't looked how he did it (yet) but it
does the trick for the screen capture stuff.

I basically did what you suggested in the first e-mail in this thread,
it's just a blind try/except error catch (with a specific error class,
though). The problem is, I have no idea on how to find out if Excel is
installed (short of going through the registry, of course), so at the
moment the code that launches Excel is a simple:

from win32com.client import Dispatch

excel = Dispatch("Excel.Application")

There might be a cleverer way to check for Excel but I am a bit short
of ideas at the moment...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 20 March 2012 20:16, werner wrote:

On 20/03/2012 19:47, Mike Driscoll wrote:
On Tue, Mar 20, 2012 at 1:39 PM, werner <wbruhin@free.fr> wrote: