Home arrow GIS Data & Resources arrow Scripts and Code arrow Python arrow Python: Read/Write to Microsoft Excel
Python: Read/Write to Microsoft Excel PDF Print E-mail

Written by Kevin Bell,


Here's some code to read or write to MS Excel...  We have reports that have been in excel, and I use this type of code to strip that info out and then push it into a gdb.  When you have thousands of spreadsheets in the same format, this is a nice way to handle it.

#name: hitMSexcel.py
#date: 20070213
#author: Kevin Bell
#email: This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
#phone: (801) 535-7131
#purpose: hit excel!

import win32com.client
xlApp = win32com.client.Dispatch("Excel.Application")
xlApp.Visible=1
xlApp.Workbooks.Add()

print xlApp.Worksheets("Sheet1").Name
xlApp.Worksheets("Sheet2").Range("A1").Value = "xxx"

cell = xlApp.Worksheets("Sheet3")
cell.Range("C3").Value = "groovy"
cell.Range("D4").Value = 9999

print cell.Range("C3").Value
print cell.Range("D4").Value



Users' Comments  
 

No comment posted

Add your comment

20, Nov. 2007
Last Updated ( 21, Nov. 2007 )
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for