To reproduce:
Merge some cells the insert a row:
private void button4_Click(object sender, EventArgs e)
{
string fileName = @"..\..\exportresult1234.xlsx";
WorkbookFormatProvidersManager.RegisterFormatProvider(new XlsxFormatProvider());
IWorkbookFormatProvider formatProvider = WorkbookFormatProvidersManager.GetProviderByName("XlsxFormatProvider");
FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 32 * 1024, false);
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();
using (fileStream)
{
for (int rowIndex = 0; rowIndex < 20; rowIndex++)
{
for (int colIndex = 0; colIndex < 20; colIndex++)
{
if (rowIndex % 4 == 0)
{
worksheet.Cells[rowIndex, colIndex, rowIndex, colIndex + 20].Merge();
worksheet.Cells[rowIndex, colIndex].SetValue("MERGED CELL");
break;
}
worksheet.Cells[rowIndex, colIndex].SetValue("text " + rowIndex + colIndex);
}
}
if (worksheet.Rows.CanInsert(0, 1))
{
RowSelection selection = worksheet.Rows[0];
selection.Insert();
}
CellIndex from = new CellIndex(0, 0);
CellIndex to = new CellIndex(0, 16);
CellSelection selection1 = worksheet.Cells[from, to];
selection1.Merge();
selection1.SetValue("Header TEXT MMMMMMMMMMMMMMMMMM");
selection1.SetHorizontalAlignment(Telerik.Windows.Documents.Spreadsheet.Model.RadHorizontalAlignment.Center);
selection1.SetFontSize(24);
formatProvider.Export(workbook, fileStream);
}
}
Workaround:
Reopen the document and then insert the row.
This item is migrated to the Telerik Document Processing portal:
http://feedback.telerik.com/Project/184/Feedback/Details/190216
Please use the new item for commenting, voting and subscribing instead of this one.