コード例 #1
0
	def __del__(self):
		if hasattr(self, 'wapp'):
			self.wapp.Quit 
			del self.wapp
		if hasattr(self, 'wpi'):
			del self.wpi
		if hasattr(self, 'des'):
			del self.des
		CheckClean()

		if not self.log_file.closed:
			self.log_file.close()

		if self.heeds_out != None:
			if not self.heeds_out.closed:
				self.heeds_out.close()

		## for HEEDS compatibility, write file heeds.complete when speedWrapper exits
		try:
			fout = open(self.GetCWD()+"\\heeds.complete", "wt", encoding='utf-8')
			fout.write("speedWrapper has exited")
			fout.close()
		except (IOError, WindowsError):
			self.Message("Cannot Open heeds.output", err=-1)
コード例 #2
0
ファイル: testMSOffice.py プロジェクト: Tomas2710/Aiidk
    xl = win32com.client.dynamic.Dispatch("Excel.Application")
    TextExcel(xl)

    try:
        print "Starting Excel 8 for generated excel8.py test..."
        mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}",
                                    0,
                                    1,
                                    2,
                                    bForDemand=1)
        xl = win32com.client.Dispatch("Excel.Application")
        TextExcel(xl)
    except ImportError:
        print "Could not import the generated Excel 97 wrapper"

    try:
        import xl5en32
        mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}",
                                    9, 1, 0)
        xl = win32com.client.Dispatch("Excel.Application.5")
        print "Starting Excel 95 for makepy test..."
        TextExcel(xl)
    except ImportError:
        print "Could not import the generated Excel 95 wrapper"


if __name__ == '__main__':
    TestAll()
    CheckClean()
    pythoncom.CoUninitialize()
コード例 #3
0
workSheet.Range("B1:D2").Value = ((1, 2, 3), (10, 20, 30))
workSheet.Range("B3:D3").Value = (u"а", u"б", u"в")
workSheet.Range("A2").Value = "=A1+1"
# або workSheet.Cells(2,1).Formula = "=A1+1"

while True:  # цикл
    if msvcrt.kbhit():  # якщо в консолі натиснута клавіша
        if ord(msvcrt.getch()) == 27: break  # завершити, якщо це Esc
    pythoncom.PumpWaitingMessages()  # обробляти події

workBook.Close(False)  # закрити робочу книгу без збереження
excelApp.Quit()  # вийти з Excel

excelApp = workBook = workSheet = None
from win32com.test.util import CheckClean
CheckClean()  # перевірити скільки COM об'єктів залишилося
pythoncom.CoUninitialize()  # відмінити ініціалізацю
CheckClean()  # перевірити скільки COM об'єктів залишилося
"""
    SheetBeforeDoubleClick
    $A$1
    1
    1
    ['Activate', 'AddComment', 'AdvancedFilter']
    $A$2
    101.0
![](fig.png)

Рисунок - Робочий лист Excel
"""