Aspose.Cells.Examples.CSharp.KnowledgeBase.ComparingVSTOWithAspose.VSTOCode.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {
                // ExStart:1
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

                DateTime start = DateTime.Now;
                Excel.Application excelApp = new Application();
                string myPath = dataDir + @"TempBook.xls";
                excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,
                Missing.Value, Missing.Value,
                Missing.Value, Missing.Value,
                Missing.Value, Missing.Value,
                Missing.Value, Missing.Value,
                Missing.Value, Missing.Value,
                Missing.Value, Missing.Value);

                for (int i = 1; i <= 1000; i++)
                {
                    for (int j = 1; j <= 20; j++)
                    {
                        excelApp.Cells[i, j] = "Row " + i.ToString() + " " + "Col " + j.ToString();
                    }
                }

                excelApp.Save(dataDir + @"TempBook1_out.xls");
                excelApp.Quit();
                DateTime end = DateTime.Now;
                TimeSpan time = end - start;
                Console.WriteLine("File Created! " + "Time consumed (Seconds): " + time.TotalSeconds.ToString());
                // ExEnd:1
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
VSTOCode