Completed
Last Updated: 05 Sep 2017 08:04 by ADMIN
ADMIN
Hristo
Created on: 25 Apr 2017 11:11
Category: GridView
Type: Bug Report
1
FIX. RadGridView - if the Excel file has an already existing sheet exception in the SpreadExportRenderer trying to add a new sheet to the document with the same name
How to reproduce check the attached project: 

Workaround: Create a custom spread export renderer

public class MySpreadExportRenderer : SpreadExportRenderer
{
    public override void AddWorksheet(string sheetName)
    {
        string name = "";

        Workbook wb = (Workbook)typeof(SpreadExportRenderer).GetField("workbook", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);
        if (sheetName == null || sheetName == string.Empty)
        {
            name = "Sheet_" + (wb.Worksheets.Count + 1);
        }
        else
        {
            name = sheetName;
        }

        if (wb.Worksheets.Where(w => w.Name == name).ToList().Count == 0)
        {
            base.AddWorksheet(sheetName);
        }
        else
        {
            typeof(SpreadExportRenderer).GetField("worksheet", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, wb.Worksheets.Add());
        }
    }
}

0 comments