Unplanned
Last Updated: 14 Aug 2017 10:46 by ADMIN
ADMIN
Dimitar
Created on: 15 Jun 2017 10:33
Category: GridView
Type: Bug Report
0
FIX. RadGridView - cells are merged incorrectly when inserting new row and there are already merged cells in the exported document (with grouping)
Use the attached project to reproduce. 
- Start the project and group by any column and export the grid.
- The same code works finme if the document is imported.

Workaround:
Edit the document after it is exported:

var provider = new XlsxFormatProvider();
var workbook = new Workbook();
using (var stream = File.OpenRead(@"D:\123.xlsx"))
{
    workbook = provider.Import(stream);
}

PatternFill solidPatternFill = new PatternFill(PatternType.Solid, System.Windows.Media.Color.FromRgb(46, 204, 113), Colors.Transparent);
CellValueFormat textFormat = new CellValueFormat("@");

Worksheet sheet = workbook.ActiveWorksheet;
CellRange range = new CellRange(0, 0, 1, 4);

CellSelection header = sheet.Cells[range];
if (header.CanInsertOrRemove(range, ShiftType.Down))
{
    header.Insert(InsertShiftType.Down);
}
header.Merge();
header.SetFormat(textFormat);
header.SetFontFamily(new ThemableFontFamily("Rockwell"));
header.SetFontSize(24);
header.SetHorizontalAlignment(Telerik.Windows.Documents.Spreadsheet.Model.RadHorizontalAlignment.Center);
header.SetVerticalAlignment(Telerik.Windows.Documents.Spreadsheet.Model.RadVerticalAlignment.Center);
header.SetFill(solidPatternFill);
header.SetValue("Test");

using (var stream = File.OpenWrite("result.xlsx"))
{
    provider.Export(workbook, stream);
}

Process.Start("result.xlsx");


Attached Files:
0 comments