Aspose.Sitefinity.FormBuilder.AsposeFormBuilder.PopulateGrid C# (CSharp) 메소드

PopulateGrid() 개인적인 메소드

PopulateGrid function which read data from execl file and show data in gridview
private PopulateGrid ( ) : void
리턴 void
        private void PopulateGrid()
        {
            try
            {
                DataTable dataTable = null;
                if (Session["AsposeDynamicFormsdataTable"] == null)
                {

                    // Check for license and apply if exists
                    string licenseFile = Server.MapPath("~/App_Data/Aspose.Total.lic");
                    if (File.Exists(licenseFile))
                    {
                        License license = new License();
                        license.SetLicense(licenseFile);
                    }


                    //Creating a file stream containing the Excel file to be opened
                    FileStream fstream = new FileStream(Server.MapPath("~/Addons/Aspose.SiteFinity.FormBuilder.ToExcel/uploads/AsposeDynamicFormsDataFile.xlsx"), FileMode.Open, FileAccess.Read);

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

                    //Accessing a worksheet using its sheet name
                    Worksheet worksheet = workbook.Worksheets["Settings"];

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

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

                    dataTable.DefaultView.Sort = "[Sort ID] ASC";
                    dataTable = dataTable.DefaultView.ToTable();

                    Session["AsposeDynamicFormsdataTable"] = dataTable;
                }
                else
                {
                    dataTable = (DataTable)Session["AsposeDynamicFormsdataTable"];
                }

                if (dataTable != null)
                {
                    GridView1.DataSource = dataTable;
                    GridView1.DataBind();
                }
            }
            catch (Exception exc)
            {
                ShowException(exc);
            }

            btnUpdate.Visible = false;
        }