Comparing Aspose.Excel performance to MS Excel performance

Hi,
I am looking to convert a system currently using MS Excel to using Aspose.Excel instead.

I’m pretty sure this will result in a major performance gain however it’ll take more than my word to convince others! With that in mind I’ve been trying to develop some side-by-side examples of C# classes carrying out the same functions on excel spreadsheets using Aspose.Excel and MS Excel’s object model.

One example of a method I am using is this one, to populate 200 columns:


//Populates a fixed number of cells with integers,

//used for performance measurement

public void populateList(Excel theExcel)

{ Cell currentCell;

for(int i = 1;i<200;i++)

{ currentCell = theExcel.Worksheets[0].Cells[“B”+i];

currentCell.PutValue(i);

}

}

This is called in a main method like so:

//Declare an instance of this class.

BasicAsposeOps ops = new BasicAsposeOps();

//Create a new aspose excel object
Excel excel1 =
new Excel();

ops.populateList(excel1);
bool hasSaved = false;
try
{ //Save the excel file as AsposeExample.xls

excel1.Save(@“C:\Visual Studio Projects\AsposeExample.xls”, FileFormatType.Default);

hasSaved = true;

}

catch(Exception e)

{ Console.WriteLine(“Error” + e);

}

if(hasSaved)

{ //This opens the new file in MS Excel

try
{ ProcessStartInfo psi = new ProcessStartInfo(@“C:\Visual Studio
Projects\AsposeExample.xls”);

Process.Start(psi);

}
catch (Exception e)

{ Console.WriteLine(“Error” + e);

}

}


What I was hoping you could help me with is to implement some kind of performance metric, I am a Java programmer and was thinking that timers used in Java could be useful but being a C# newbie I don’t know how it is done in that language, or if there are better alternatives.

I know this is more of a programming question than an aspose question, but any insights you could give me would be greatly appreciated, thanks.

(By the way, and I’m really pushing my luck here, but does anyone know how I could write the populateList method using MS Excel object model? Its so much harder to use than aspose I can’t get my head round itWink)

You can add the blue lines of code to test the elapesed time:

BasicAsposeOps ops = new BasicAsposeOps();

DateTime start = DateTime.Now;

//Create a new aspose excel object
Excel excel1 =
new Excel();

ops.populateList(excel1);
bool hasSaved = false;
try
{ //Save the excel file as AsposeExample.xls

excel1.Save(@“C:\Visual Studio Projects\AsposeExample.xls”, FileFormatType.Default);

hasSaved = true;

DateTime end = DateTime.Now;
TimeSpan span = end - start;
Console.WriteLine(span.TotalSeconds);
}

catch(Exception e)

{ Console.WriteLine(“Error” + e);

}

I test your case in my machine. The elapsed time is 0.7s at the first time to run it, and 0.25s in later time. When I increase the loop count to 2000, the elapsed time is 0.45s. And when I increase the loop count to 20000, the elapsed time is 1.5s.

great thanks, your service on this site is excellent! Much appreciated!