the-generalist.com

  • Increase font size
  • Default font size
  • Decrease font size
joomla templates, wordpress themes, drupal, datalife engine, graphics, seo,
The Generalist - A little bit of this, a little bit of that...

Writing to an Excel Cell Using Python

E-mail Print PDF

This is just a simple example showing how to write to a cell in Excel using Python.  I'm assuming you've already set up your Python installation to work with Excel.

import win32com.client

Excel = win32com.client.Dispatch("Excel.Application")
Excel.Visible = True

ThisWorkbook = Excel.Workbooks.Add()
ThisSheet = ThisWorkbook.ActiveSheet

ThisSheet.Cells(1, 1).Value = '1'

 

Last Updated on Thursday, 08 July 2010 00:02
 

Setting Up Python to Work with Excel

E-mail Print PDF

Visual Basic for Applications (VBA) is a useful language for working in Excel.  It's built in to Excel so you won't have to install anything new on an end-users system.  Also, you can record macros and then view the code to help you get started.  I often find myself solving a problem quickly by recording a couple macros and adding a loop to the code.  If you want to interface to something outside of Excel, for instance a MySQL database, I recommend using Python.  The setup is simple and will give you another tool to work with if you ever run into a limitation in VBA.

Last Updated on Friday, 10 June 2011 15:42
 


Page 35 of 35

Main Menu