ich möchte in Python in eine existierende excel Datei Messwerte schreiben. meine Programm sieht wie folgt aus:
Code: Alles auswählen
cTH.Print('Excel Tabelle Write Zelle ' + sFile + ' ' + sTable + ' ' + str(iColumn) + ' ' + str(iLine) + ' ' + sCell, 'INFO')
import xlwt
from xlwt import workbook
try:
book = xlwt.workbook(sFile)
sheet1 = book.get_sheet(sTable)
sheet1.write(iLine, iColumn,sCell)
book.save(sFile)
iResult = 1
#book = Workbook(sFile)
#sheet = book.get_sheet(sTable)
#sheet.write(iLine, iColumn, sCell)
#book.save("sFile")
#iResult = 1
except:
Report.createSubTest('Excel Tabelle Write Zelle' , 0 )
Report.createCommentSubTest(' Fehler beim Schreiben von ' + sFile + ' ' + sTable + ' ' + str(iColumn) + ' ' + str(iLine) + ' ' + sCell)
iResult = 0
raise
Code: Alles auswählen
2011-07-28 14:36:27 MainThread !!! exception-name: AttributeError
2011-07-28 14:36:27 MainThread !!! exception-arguments: 'module' object has no attribute 'workbook'
2011-07-28 14:36:27 MainThread !!! exception-traceback: File "D:\EXAM\Programme\EXAM\plugins\de.exam.prunner_3.0.1.201105230923\pRunner\loop.py", line 148, in commandLoop
2011-07-28 14:36:27 MainThread command: exec(execFileName + '.main()')
2011-07-28 14:36:27 MainThread !!! exception-traceback: File "<string>", line 1, in <module>
2011-07-28 14:36:27 MainThread command:
2011-07-28 14:36:27 MainThread command: testFlow('', '00000000-0000-0000-0000-000000000000')
2011-07-28 14:36:27 MainThread command: iResult = _0._e.UmlClass_a29a2d3c1051729de04400144f6890e0.getInstance().Excel_Tabelle_Write_Zelle_4(sFile = 'C:/TEMP/Messwer_Test.xls', sTable =
'Sheet4', iColumn = 0, iLine = 0, sCell = 'TEST_01')
2011-07-28 14:36:27 MainThread command: book = xlwt.workbook(sFile)
mit dem folgende programme Stück
Code: Alles auswählen
cTH.Print('Excel Tabelle Write Zelle ' + sFile + ' ' + sTable + ' ' + str(iColumn) + ' ' + str(iLine) + ' ' + sCell, 'INFO')
import xlwt
from MSExcel import Workbook
try:
book = workbook(sFile)
sheet1 = book.get_sheet(sTable)
sheet1.write(iLine, iColumn,sCell)
book.save(sFile)
iResult = 1
except:
Report.createSubTest('Excel Tabelle Write Zelle' , 0 )
Report.createCommentSubTest(' Fehler beim Schreiben von ' + sFile + ' ' + sTable + ' ' + str(iColumn) + ' ' + str(iLine) + ' ' + sCell)
iResult = 0
raise
Fehlermeldung in diese Art:
Code: Alles auswählen
2011-07-28 14:26:19 MainThread !!! exception-name: ImportError
2011-07-28 14:26:19 MainThread !!! exception-arguments: cannot import name workbook
2011-07-28 14:26:19 MainThread !!! exception-traceback: File "D:\EXAM\Programme\EXAM\plugins\de.exam.prunner_3.0.1.201105230923\pRunner\loop.py", line 148, in commandLoop
2011-07-28 14:26:19 MainThread command: exec(execFileName + '.main()')
2011-07-28 14:26:19 MainThread !!! exception-traceback: File "<string>", line 1, in <module>
2011-07-28 14:26:19 MainThread command:
2011-07-28 14:26:19 MainThread command: testFlow('', '00000000-0000-0000-0000-000000000000')
2011-07-28 14:26:19 MainThread command: iResult = _0._e.UmlClass_a29a2d3c1051729de04400144f6890e0.getInstance().Excel_Tabelle_Write_Zelle_4(sFile = 'C:/TEMP/Messwer_Test.xls', sTable =
'Sheet4', iColumn = 0, iLine = 0, sCell = 'TEST_01')
2011-07-28 14:26:19 MainThread command: from xlwt import workbook
was mache ich falsch?
kann jemand mir dabei helfen Bitte
Grüße
Lyva