Free Support Forum - aspose.com

Performance with delete row

I have 2 problems with the DeleteRow method.

It takes about 50 seconds to delete 10 rows, what can cause this?

Also, it deletes data that should not be deleted. With the code I wrote below, you will see that some formula are deleted in different rows/columns. I attached the file that I want to delete rows.

Aspose.Cells.Workbook w = new Workbook();

w.Open("C:\\deleterow.xls");

Aspose.Cells.Worksheet xlSheet = w.Worksheets[0];

xlSheet.Cells.DeleteRow(8);

xlSheet.Cells.DeleteRow(15);

xlSheet.Cells.DeleteRow(18);

xlSheet.Cells.DeleteRow(34);

w.Save("C:\\aspose.xls");

Thank you

Alexandre

Dear Alexandre,

I tried your sample code and it runs only 2.8 seconds in my machine. What's the configuration of your machine?

My laptop is:

Pentium M 1.4G, 512MRAM, WindowXP

For lost formula issue, I will check and fix it soon.

Pentium D 2.8GHz, 2GB RAM, Windows XP Pro

But I found that when I execute the code from visual studio, it takes 25 seconds (debug or release it's the same performance).

But when I execute the exe directly, it takes less than 1 second.

Hi,

Thanks for considering Aspose.

We will try to find out and resolve this issue soon.

Thanks for your patience.

Regards

Amjad Sahi

Aspose Nanjing Team

Really a strange issue for this performance. How do you " execute the code from visual studio"?

I create a console application which include your sample code. And I hit F5 to run it line by line in debug mode and it takes 13 seconds to run the whole delete row routine. In release mode, I hit F5 and it takes 9 seconds to run it.

If I run without debugging, it takes only 2.5 seconds.

I use vs.net 2002.

Aspose.Cells.Workbook w = new Workbook();

w.Open("c:\\test\\deleterow.xls");

DateTime start = DateTime.Now;

Aspose.Cells.Worksheet xlSheet = w.Worksheets[0];

xlSheet.Cells.DeleteRow(8);

xlSheet.Cells.DeleteRow(15);

xlSheet.Cells.DeleteRow(18);

xlSheet.Cells.DeleteRow(34);

DateTime end = DateTime.Now;

TimeSpan span = end - start;

Console.WriteLine(span.TotalSeconds);

w.Save("d:\\test\\abc.xls");

I think this issue may be caused by:

1. When running in vs.net, vs.net will monitor the run process which degrade the performance.

2. If your application is an aspnet application, it will also run slower in vs.net.

I execute it by pressing F5 too.

I tested with your code (in a console application... earlier it was in a windows application) on my own computer (AMD64 Mobile 1.8ghz 512 mb ram). I use VS .Net 2003 with framework 1.1 SP1 (same version I have on the other computer).

Debug: 9.8sec
Release: 8.2 sec
Outside VS: 0.5sec

Anyway, the most important is the performance "outside VS", but it's really strange that it makes such a big difference in that case!