This project has moved and is read-only. For the latest updates, please go here.

InsertRowsBelow - is there a more efficient way

Feb 15, 2012 at 4:06 PM


i just created a simple example. I have a small table (3cols, 2 data rows). This table will be extended to 10.000 data rows. After that a list will fill the 10.000 data rows.

The example takes 27s on my laptop. The profiler shows that 86% of total time is spent in Insert.RowsBelow

        public new IXLTableRows InsertRowsBelow(int numberOfRows)
            var rows = new XLTableRows(Worksheet.Style);
            var inserted = base.InsertRowsBelow(numberOfRows);                          <--  1%
            inserted.ForEach(r => rows.Add(new XLTableRow(this, r as XLRangeRow)));     <-- 85%
            return rows;

Filling the data is done <1s. The remaining time is used for the workbook.saveas routine.

The function doing most individual work is this one:
System.MulticastDelegate.RemoveImpl(class System.Delegate)

I'm wondering why the creation of 10.000 rows takes so long and if there could be a more efficient way to do that?
thx, Peter
Feb 17, 2012 at 6:31 AM

I'm working on this. It's already inserting the 10K rows in ~1s but I had to break two unit tests so I now have to resolve that issue before checking the changes in.

Thanks for the feedback,

Feb 17, 2012 at 1:45 PM

Great. Sounds promising.

I just discovered an interesting point. When i open an Excel with an existing table, i can expand the table with 40.000 rows within 2-3s with the old coding.

So why is it so different to the example listed above?

thx, Peter

Mar 9, 2012 at 7:38 AM
Edited Mar 9, 2012 at 7:38 AM

Today was the first time in a few weeks I've been able to work for a couple of hours straight. I can't wait to start knocking down the grown list of issues =)

I swear I'm almost done with this one but I'll continue tomorrow (VS crashing is a sign I need to go to bed).

Mar 10, 2012 at 4:09 AM

Done! (finally)

Pick up the latest check-in...

Mar 13, 2012 at 6:14 PM

Works fantastic! Well done, as always !!