Aspose.Plugins.AsposeVSOpenXML.Form1.BTN_NonStronglyExport_Click C# (CSharp) Method

BTN_NonStronglyExport_Click() private method

private BTN_NonStronglyExport_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void BTN_NonStronglyExport_Click(object sender, EventArgs e)
        {
            //Creating a file stream containing the Excel file to be opened
            FileStream fstream = new FileStream(FOD_OpenFile.FileName, FileMode.Open);

            //Instantiating a Workbook object
            //Opening the Excel file through the file stream
            Workbook workbook = new Workbook(fstream);

            //Accessing the first worksheet in the Excel file
            Worksheet worksheet = workbook.Worksheets[0];

            //Exporting the contents of 2 rows and 2 columns starting from 1st cell to DataTable
            DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0, 0, 2, 2, true);

            //Binding the DataTable with DataGrid
            dataGridView2.DataSource = dataTable;

            //Closing the file stream to free all resources
            fstream.Close();
        }