| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 93:
 94:
 95:
 96:
 97:
 98:
 99:
 100:
 101:
 102:
 103:
 104:
 105:
 106:
 107:
 108:
 109:
 110:
 111:
 112:
 113:
 114:
 115:
 116:
 117:
 
 | public void exportXLS(System.ComponentModel.BackgroundWorker worker, System.ComponentModel.DoWorkEventArgs e){
 Excel.Application excapp = null;
 Excel.Workbooks books = null;
 Excel.Workbook workbook = null;
 Excel.Sheets sheets = null;
 Excel.Worksheet sheet = null;
 Excel.Range firstRow = null;
 
 excapp = new Excel.Application();
 books = excapp.Workbooks;
 workbook = books.Add(Excel.XlWBATemplate.xlWBATWorksheet);
 sheets = workbook.Worksheets;
 sheet = sheets[1];
 
 object n = null;
 string colLast = null;
 
 try
 {
 colLast = "U";
 int rowCurrent = 1;
 n = System.Reflection.Missing.Value;
 
 sheet.Cells[rowCurrent, 1] = "Überschrift";
 sheet.Cells[rowCurrent, 21] = "Überschrift";
 
 rowCurrent++;
 
 foreach (signFlow flow in container)
 {
 if (worker.CancellationPending)
 {
 e.Cancel = true;
 File.Delete(path);
 break;
 }
 else
 {
 int colCurrent = 1;
 
 sheet.Cells[rowCurrent, colCurrent] = flow.callIntSign.getName;
 colCurrent++;
 sheet.Cells[rowCurrent, colCurrent] = flow.callMetaData.getcomment;
 colCurrent++;
 }
 }
 
 sheet.get_Range("A1", colLast + rowCurrent).Font.Name = "Arial Narrow";
 sheet.get_Range("A1", colLast + rowCurrent).Font.Size = 8;
 sheet.get_Range("A1", colLast + "1").Font.Bold = true;
 sheet.get_Range("M1", "U1").Orientation = Excel.XlOrientation.xlUpward;
 sheet.get_Range("A1", colLast + "1").HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
 sheet.get_Range("A1", "A1").ColumnWidth = 20;
 sheet.get_Range("U1", "U1").ColumnWidth = 20;
 sheet.get_Range("A1", colLast + rowCurrent).Cells.WrapText = true;
 sheet.get_Range("A1", colLast + rowCurrent).AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true);            firstRow = sheet.get_Range("B2", "B2");
 firstRow.Activate();
 firstRow.Select();
 firstRow.Application.ActiveWindow.FreezePanes = true;
 
 if (e.Cancel != true)
 {
 workbook.SaveAs(path, n, n,
 n, n, n, Excel.XlSaveAsAccessMode.xlNoChange,
 n, n, n, n, n);
 workbook.Close(false, n, n);
 excapp.Workbooks.Close();
 excapp.Application.Quit();
 excapp.Quit();
 }
 }
 catch (Exception ex)
 {
 MessageBox.Show("Fehler beim speichern des Excel-Exports " + ex.Message);
 }
 finally
 {
 
 while (Marshal.FinalReleaseComObject(firstRow) > 0) ;
 while (Marshal.FinalReleaseComObject(sheet) > 0) ;
 while (Marshal.FinalReleaseComObject(sheets) > 0) ;
 while (Marshal.FinalReleaseComObject(workbook) > 0) ;
 while (Marshal.FinalReleaseComObject(books) > 0) ;
 while (Marshal.FinalReleaseComObject(excapp) > 0) ;
 
 firstRow = null;
 sheet = null;
 sheets = null;
 workbook = null;
 books = null;
 excapp = null;
 GC.Collect();
 GC.WaitForPendingFinalizers();
 GC.Collect();
 }
 }
 |