def onExcel(self, event): self.commit() export = getExportGrid() xlFName = Utils.getMainWin().getFormatFilename('excel') xlFName = os.path.splitext( xlFName)[0] + '-Categories' + os.path.splitext(xlFName)[1] wb = xlsxwriter.Workbook(xlFName) sheetCur = wb.add_worksheet(_('Categories')) export.toExcelSheetXLSX(ExportGrid.getExcelFormatsXLSX(wb), sheetCur) try: wb.close() if Utils.getMainWin().launchExcelAfterPublishingResults: Utils.LaunchApplication(xlFName) Utils.MessageOK( self, u'{}:\n\n {}'.format(_('Excel file written to'), xlFName), _('Excel Write')) except IOError: Utils.MessageOK( self, u'{} "{}"\n\n{}\n{}'.format( _('Cannot write'), xlFName, _('Check if this spreadsheet is already open.'), _('If so, close it, and try again.')), _('Excel File Error'), iconMask=wx.ICON_ERROR)