public void Dispose() { try { if (mBook != null) { mBook.Close(false, MISSING, MISSING); mBook = null; } } catch {} try { if (mSheet != null) { mSheet = null; } } catch {} try { if (mExcelApp != null) { mExcelApp.Quit(); mExcelApp = null; } } catch {} }
//Oluşturulan veri seti excell yazılır. public void exceleKaydet(int veriCount) { try { Microsoft.Office.Interop.Excel.Application xlOrn = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook wb = xlOrn.Workbooks.Add(Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet); Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlOrn.ActiveSheet; for (int i = 0; i < islemler.feature.Count; i++) { ws.Cells[1, i + 1] = islemler.feature.ElementAt(i); for (int j = 0; j < veriCount; j++) { ws.Cells[j + 2, i + 1] = islemler.dataNorm.ElementAt((i * veriCount) + j); } } string path = Application.StartupPath.ToString() + "\\data" + islemler.rastgele.Next(1, 100) + ".xlsx"; wb.SaveAs(path, Excel.XlFileFormat.xlWorkbookNormal); wb.Close(true); MessageBox.Show("Excel dosyası " + path + " komununda oluşturuldu! \nDoğrusal regresyon analizi sonucu ise form ekranın da gösterilmiştir."); } catch (Exception) { throw; } }