home *** CD-ROM | disk | FTP | other *** search
/ One Click 11 / OneClick11.iso / Bancos de Dados / Conversao / Mysql2Excel / Setup.exe / Mysql2Excel.exe / class_excel.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-06-23  |  2.3 KB  |  58 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.2)
  3.  
  4.  
  5. class myExcel:
  6.     
  7.     def __init__(self, filename = None):
  8.         Dispatch = Dispatch
  9.         import win32com.client
  10.         self.xlApp = Dispatch('Excel.Application')
  11.         if filename:
  12.             self.filename = filename
  13.             self.xlBook = self.xlApp.Workbooks.Open(filename)
  14.         else:
  15.             self.xlBook = self.xlApp.Workbooks.Add()
  16.             self.filename = ''
  17.  
  18.     
  19.     def save(self, newfilename = None):
  20.         if newfilename:
  21.             self.filename = newfilename
  22.             self.xlBook.SaveAs(newfilename)
  23.         else:
  24.             self.xlBook.Save()
  25.  
  26.     
  27.     def close(self):
  28.         self.xlBook.Close(SaveChanges = 0)
  29.         del self.xlApp
  30.  
  31.     
  32.     def getCell(self, sheet, row, col):
  33.         sht = self.xlBook.Worksheets(sheet)
  34.         return sht.Cells(row, col).Value
  35.  
  36.     
  37.     def setCell(self, sheet, row, col, value):
  38.         sht = self.xlBook.Worksheets(sheet)
  39.         sht.Cells(row, col).Value = value
  40.  
  41.     
  42.     def fixStringsAndDates(self, aMatrix):
  43.         newmatrix = []
  44.         for row in aMatrix:
  45.             newrow = []
  46.             for cell in row:
  47.                 if type(cell) is UnicodeType:
  48.                     newrow.append(str(cell))
  49.                 elif type(cell) is TimeType:
  50.                     newrow.append(int(cell))
  51.                 
  52.             
  53.             newmatrix.append(tuple(newrow))
  54.         
  55.         return newmatrix
  56.  
  57.  
  58.