﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sahandhyd
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new main());
            main m = new main();
            m.FormBorderStyle = FormBorderStyle.FixedSingle;
            m.MaximizeBox = false;
            m.MinimizeBox = false;
            /* 
              using System;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (Exception ex)
            {
                obj = null;
                MessageBox.Show("Unable to release the Object " + ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        } 


        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;

            

            xlApp = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(Application.StartupPath + "\\Book1.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            range = xlWorkSheet.UsedRange;

            for (int columnCounter = 1; columnCounter <= range.Columns.Count; columnCounter++)
            {
                this.dataGridView1.Columns.Add(xlWorkSheet.Cells[1, columnCounter].Value2, xlWorkSheet.Cells[1, columnCounter].Value2);
            }
            //get the value of each excel cell and put into this variable
            string str;
            //Loop counters
            int rowCounter = 0;
            int columnCounter2 = 0;

            for (rowCounter = 2; rowCounter <= range.Rows.Count; rowCounter++)
            {
                //Create a new row into the datagridview
                this.dataGridView1.Rows.Add();
                for (columnCounter2 = 1; columnCounter2 <= range.Columns.Count; columnCounter2++)
                {
                    str = Convert.ToString((range.Cells[rowCounter, columnCounter2] as Excel.Range).Value2);
                    //add the value of excel file into the new row
                    this.dataGridView1.Rows[rowCounter - 2].Cells[columnCounter2 - 1].Value = str;
                }
            }
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }
    }
}
*/
        }
    }
}
