Beispiel #1
0
        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 {}
        }
Beispiel #2
0
        //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;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Change the CUrrent worksheet (current WOrking Sheet for other function)
        /// Also Change the CurrentSheetIndex
        ///
        /// EXCEPTION: If the Worksheet is not exist, IndexOutOfRangeException will throw out
        /// </summary>
        /// <param name="pnWorksheetIndex">Sheet index to change</param>
        /// <returns></returns>
        public Worksheet ChangeCurrentWorksheet(int pnWorksheetIndex)
        {
            /// Get the worksheet
            mSheet = GetWorksheet(pnWorksheetIndex);

            /// change the Current Worksheet Index
            mnCurrentSheetIndex = pnWorksheetIndex;

            return(mSheet);
        }
Beispiel #4
0
        /// <summary>
        /// Save the Current working workbook
        /// CLose the Current working workbook
        /// Quit the Excel Interop process
        ///
        /// After calling this function, you should NOT use this Builder ANYMORE
        /// </summary>
        public void CloseWorkbook()
        {
            mExcelApp.ScreenUpdating = true;
            mExcelApp.Visible        = false;
            mExcelApp.DisplayAlerts  = false;

            mBook.Save();
            mBook.Close(Type.Missing, Type.Missing, Type.Missing);
            mSheet = null;
            mBook  = null;

            if (mExcelApp != null)
            {
                mExcelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(mExcelApp);
                mExcelApp = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }