Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Import from xlsx with high speed

$
0
0

Hi

I used the following code for import it works slowly,how can I improve itSpeed?I don't want to import from xml,

  private void Button_Click(object sender, RoutedEventArgs e)
        {

            OpenFileDialog flDialog = new OpenFileDialog();

            flDialog.Filter = "Excel Files(*.xlsx)|*.xlsx";



            bool res = (bool)flDialog.ShowDialog();



            if (res)
            {

                FileInfo fs = flDialog.File;



                string fileName = fs.Name;



                #region Reading Data From Excel File



                dynamic objExcel = AutomationFactory.CreateObject("Excel.Application");



                //Open the Workbook Here

                dynamic objExcelWorkBook =

                    objExcel.Workbooks.Open(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

                    + "\\" + fileName);

                //Read the Worksheet

                dynamic objActiveWorkSheet = objExcelWorkBook.ActiveSheet();

                //Cells to Read

                dynamic objCell_1, objCell_2;



                //Iterate through Cells

                for (int count = 2; count < 300; count++)
                {

                    objCell_1 = objActiveWorkSheet.Cells[count, 1];

                    objCell_2 = objActiveWorkSheet.Cells[count, 2];

                    populationData.Add

                        (

                            new PopulationClass()

                            {

                                StateName = objCell_1.Value,

                                Population = objCell_2.Value

                            }

                        );

                }



                dgExcelData.ItemsSource = populationData;



                #endregion
           

            }
            
         
        }


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>