For example, I have a code like this :
DateTime dtBegin = DateTime.Now;
Excel excel = new Excel();
Worksheet sheet = excel.Worksheets[0];
for ( int i = 0; i < 65530; i = i + 5 )
{
sheet.Cells[i,0].PutValue( i );
Range range = sheet.Cells.CreateRange(i, (byte)0, 5, 5);
range.SetOutlineBorder( BorderType.TopBorder, CellBorderType.Thick,
Color.Black );
range.SetOutlineBorder( BorderType.BottomBorder, CellBorderType.Thick,
Color.Black );
range.SetOutlineBorder( BorderType.LeftBorder, CellBorderType.Thick,
Color.Black );
range.SetOutlineBorder( BorderType.RightBorder, CellBorderType.Thick,
Color.Black );
}
DateTime dtEnd = DateTime.Now;
TimeSpan tsDiff = dtEnd.Subtract(dtBegin);
label1.Text = string.Format("{0} min {1} sec {2} ms", tsDiff.Minutes, tsDiff.Seconds, tsDiff.Milliseconds);
excel.Save(@"C:\rem1.xls");
excel = null;
dtEnd = DateTime.Now;
tsDiff = dtEnd.Subtract(dtBegin);
label2.Text = string.Format("{0} min {1} sec {2} ms", tsDiff.Minutes, tsDiff.Seconds, tsDiff.Milliseconds);
I have got the following results :
memory usage 150300 kb
time before saving 6 sec 906 ms
time after saving 28 sec 593
Are there any ways to reduce both memory usage and saving time ? Each time for every range I may have a different styles.