class ExcelDocument():
"""
Some convenience methods for Excel documents accessed
through COM.
"""
def __init__(self, visible=True):
self.app = Dispatch("Excel.Application")
self.app.Visible = visible
self.sheet = 1
def new(self, filename=None):
"""
Create a new Excel workbook. If 'filename' specified,
use the file as a template.
"""
self.app.Workbooks.Add(filename)
def open(self, filename):
"""
Open an existing Excel workbook for editing.
"""
self.app.Workbooks.Open(filename)
I am trying to manipulate excel files with pythin. The problem is that I have no control over the path of the files. By default, the path is "My Documents". I would like to change it to the path where the .py file is. For example, when I do
exc = ExcelDocument()
exc.open("some_file.xls")
It will open "some_file.xls" if there is one in "My Documents" otherwise it will display an error.
I am sure there is a way to overcome this. Does anyone know?
Thanks and Cheers!