Excel named ranges and page breaks are not moving down/up when I insert/delete rows in a workshet. Looks like this occurs on when I make a copy fo the worksheet.
See the below code snippet and attached excel file to reproduce the problem.
Workbook book = new Workbook();
book.Open(@"C:\temp\test.xls");
// This works fine.
Worksheet sheet = book.Worksheets[0];
Range r1 = book.Worksheets.GetRangeByName("TA");
Console.WriteLine("Row Index of the range {0} : {1}", "TA", r1.FirstRow);
Console.WriteLine("Inserting 10 rows after the range 'TA'");
sheet.Cells.InsertRows(r1.FirstRow - 10, 5);
Range r2 = book.Worksheets.GetRangeByName("TA");
Console.WriteLine("Row Index of the range {0} : {1}", "TA", r2.FirstRow);
//This Section doesn't work as expected
// Make a copy of the worksheet
Console.WriteLine("Make a copy of the worksheet");
int idx = book.Worksheets.AddCopy(0);
Worksheet sheet2 = book.Worksheets[idx];
Range r3 = book.Worksheets.GetRangeByName("TA");
Console.WriteLine("Row Index of the range {0} : {1}", "TA", r3.FirstRow);
Console.WriteLine("Inserting 10 rows after the range 'TA'");
sheet2.Cells.InsertRows(r3.FirstRow - 10, 5);
Range r4 = book.Worksheets.GetRangeByName("TA");
Console.WriteLine("Row Index of the range {0} : {1}", "TA", r4.FirstRow);
Console.ReadLine();
//book.Save(@"C:\temp\PolicyStatement.xls");