Loading writeExcel.py +18 −1 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,16 @@ class ExcelWriter: When inserting an entry, it might be a test being re-run. In that case, When inserting an entry, it might be a test being re-run. In that case, the row containing that test needs to be updated, as opposed to appending the row containing that test needs to be updated, as opposed to appending the entry to the end of the file. the entry to the end of the file. This method finds that row, returning the row number, or -1 in the case where that test is not in the report yet. """ """ for cell in self.ws["A"]: if cell.value is None: return -1 elif cell.value == id: print("MATCH with id {} at row {}".format(id, cell.row)) return cell.row return -1 def getLastRow(self): def getLastRow(self): for cell in self.ws["A"]: for cell in self.ws["A"]: Loading @@ -30,10 +39,18 @@ class ExcelWriter: return cell.row + 1 return cell.row + 1 def writeTestEntry(self, testEntry): def writeTestEntry(self, testEntry): existingEntryRow = self.getEntryWithId(testEntry.id) lastRow = self.getLastRow() lastRow = self.getLastRow() # Use the above two values to pick a row entryRow = existingEntryRow if existingEntryRow != -1 else lastRow # Pick a cell color based on test outcome cellCol = ExcelWriter.PASS_COL if testEntry.result == "PASS" else ExcelWriter.FAIL_COL cellCol = ExcelWriter.PASS_COL if testEntry.result == "PASS" else ExcelWriter.FAIL_COL # Test entry as a list entryVals = testEntry.asList() entryVals = testEntry.asList() for col, cellValue in zip(self.ws.iter_cols(min_row=lastRow, max_col=len(entryVals), max_row=lastRow), entryVals): for col, cellValue in zip(self.ws.iter_cols(min_row=entryRow, max_col=len(entryVals), max_row=entryRow), entryVals): for cell in col: for cell in col: cell.value = cellValue cell.value = cellValue cell.fill = PatternFill("solid", fgColor=cellCol)# cellCol cell.fill = PatternFill("solid", fgColor=cellCol)# cellCol Loading Loading
writeExcel.py +18 −1 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,16 @@ class ExcelWriter: When inserting an entry, it might be a test being re-run. In that case, When inserting an entry, it might be a test being re-run. In that case, the row containing that test needs to be updated, as opposed to appending the row containing that test needs to be updated, as opposed to appending the entry to the end of the file. the entry to the end of the file. This method finds that row, returning the row number, or -1 in the case where that test is not in the report yet. """ """ for cell in self.ws["A"]: if cell.value is None: return -1 elif cell.value == id: print("MATCH with id {} at row {}".format(id, cell.row)) return cell.row return -1 def getLastRow(self): def getLastRow(self): for cell in self.ws["A"]: for cell in self.ws["A"]: Loading @@ -30,10 +39,18 @@ class ExcelWriter: return cell.row + 1 return cell.row + 1 def writeTestEntry(self, testEntry): def writeTestEntry(self, testEntry): existingEntryRow = self.getEntryWithId(testEntry.id) lastRow = self.getLastRow() lastRow = self.getLastRow() # Use the above two values to pick a row entryRow = existingEntryRow if existingEntryRow != -1 else lastRow # Pick a cell color based on test outcome cellCol = ExcelWriter.PASS_COL if testEntry.result == "PASS" else ExcelWriter.FAIL_COL cellCol = ExcelWriter.PASS_COL if testEntry.result == "PASS" else ExcelWriter.FAIL_COL # Test entry as a list entryVals = testEntry.asList() entryVals = testEntry.asList() for col, cellValue in zip(self.ws.iter_cols(min_row=lastRow, max_col=len(entryVals), max_row=lastRow), entryVals): for col, cellValue in zip(self.ws.iter_cols(min_row=entryRow, max_col=len(entryVals), max_row=entryRow), entryVals): for cell in col: for cell in col: cell.value = cellValue cell.value = cellValue cell.fill = PatternFill("solid", fgColor=cellCol)# cellCol cell.fill = PatternFill("solid", fgColor=cellCol)# cellCol Loading