ExportToExcelML Problem Q2 2010

9 posts, 0 answers
  1. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 20 Jul 2010 Link to this post

    Hello,

    RunExport throws now this Exception: "Cannot find any base cell element!".

    My Code:

    ExportToExcelML exporter = new ExportToExcelML(gridview);
                exporter.HiddenColumnOption = HiddenOption.DoNotExport;
                exporter.ExportVisualSettings = true;
                exporter.SummariesExportOption = SummariesOption.ExportOnlyBottom;
                exporter.HiddenRowOption = HiddenOption.DoNotExport;
                exporter.SheetName = "Export";

                string filename = Path.Combine(Path.GetTempPath(), "excel_export.xls");

                try
                {
                    exporter.RunExport(filename);
                    return filename;
                }
                catch (Exception e)
                {
                    return string.Empty;
                }

    I have no idea what i have to change.

    Regards,
    Thomas
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 Jul 2010 Link to this post

    Hi Thomas,

    Thank you for writing.

    Actually, this is a know issue with Q2 2010 release. Most probably you have some conditional formatting applied to the RadGridView and a bug with determining the base cell element leads to the described exception. Unfortunately, there is not a suitable work-around for this situation except removing the conditional formatting. The good news is that we have already fixed this and this issue will not be presented in the upcoming service pack.

    Please, excuse us for the caused inconvenience. Let me know if you have any additional questions.

    Regards,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 22 Jul 2010 Link to this post

    My implementation doesnt use ConditionalFormatting.

    It is a derived RadGridView with TextBox- and DecimalColumns with bounded data. Also i am using CellFormatting, CellPaint and the new Style object.

    Regards,
    Thomas
  5. Bernd Mueller
    Bernd Mueller avatar
    38 posts
    Member since:
    May 2010

    Posted 23 Jul 2010 Link to this post

    Hello everyone,

    this error message also comes up when i modify the back color of a cell element.
    The strange thing is that it is only a problem with the backcolor of a cell in the non odd row.
    @Telerik-Team: Please try this code and you will get the error when doing the excel export:

    Private Sub RadGrid1CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGrid1.CellFormatting
                If e.CellElement.RowElement.IsOdd Then
                    ' no problem
                    e.CellElement.BackColor = Color.White
                Else
                    ' export not working when changing back color
                    e.CellElement.BackColor = Color.White
                End If
    End Sub
  6. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 26 Jul 2010 Link to this post

    Hi guys,

    Thank you for your feedback.

    Actually the reason for the exception is the same for the quoted scenarios as when there is a Conditional Formatting applied. We believe that we have already addressed that and the fix will be available in the upcoming service pack release.

    Once again, please excuse us for the inconvenience. 

    Regards,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 09 Aug 2010 Link to this post

    Hello,

    when is the release planned?
  8. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 Aug 2010 Link to this post

    Hi Thomas,

    The Q2 2010 Service Pack 1 is already released. Please download it and let me know whether you experience any issues.

    Kind regards,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. codicezerouno
    codicezerouno avatar
    22 posts
    Member since:
    Feb 2009

    Posted 28 Sep 2010 Link to this post

    Hi,

    I think I'm figuring out a similar problem:
    I'm formatting a gridview by using CellFormatting event; then I need to export grid to excel but cell colors are not exported.

    I tried this workaround by using event ExcelCellFormatting of the exporter:

    void xlsExporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
            {
                if (e.GridRowInfoType == typeof(Telerik.WinControls.UI.GridViewDataRowInfo))
                {
                    //e.CancelConditionalFormatting = true;
                    var gridCellElement = dataGrid.TableElement.GetCellElement(dataGrid.Rows[e.GridRowIndex], dataGrid.Columns[e.GridColumnIndex]);
                    if (gridCellElement != null)
                        e.ExcelStyleElement.InteriorStyle.Color = gridCellElement.BackColor;
                }
            }

    Now I get cell colors exported but only if the entire grid is visible.

    Where am I wrong? Could you help to solve this problem?

    Thanks in advance. Stefano.
  10. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 01 Oct 2010 Link to this post

    Hello Stefano Cadò,

    Thank you for writing.

    You have experienced the described issue because of the grid virtualization. If the cell is not visible, its cell element is not created and GetCellElement returns null. You can get the virtualized cell element as shown below:
    public static GridCellElement GetCellElement(RadGridView gridInstance, int rowIndex, int colIndex)
            {
                GridCellElement cellElement =
                    gridInstance.TableElement.GetCellElement(gridInstance.Rows[rowIndex], gridInstance.Columns[colIndex]);
      
                if (cellElement == null)
                {
                    GridTableElement tableElement = gridInstance.TableElement;
                    RowElementProvider rowProvider = tableElement.RowScroller.ElementProvider as RowElementProvider;
                    CellElementProvider cellProvider = tableElement.ColumnScroller.ElementProvider as CellElementProvider;
      
                    GridDataRowElement gridRowElement = rowProvider.GetElement(gridInstance.Rows[rowIndex], null) as GridDataRowElement;
                    gridRowElement.InitializeRowView(tableElement);
                    gridRowElement.Initialize(gridInstance.Rows[rowIndex]);
                    gridRowElement.SuspendLayout();
      
                    GridVirtualizedCellElement virtualizedCellElement =
                                cellProvider.GetElement(gridInstance.Columns[colIndex], gridRowElement) as GridVirtualizedCellElement;
                    gridRowElement.Children.Add(virtualizedCellElement);
                    virtualizedCellElement.Attach(gridInstance.Columns[colIndex], gridRowElement);
                    virtualizedCellElement.SetContent();
      
                    cellElement = virtualizedCellElement;
      
                    gridRowElement.ResumeLayout(false);
                }
      
                if (cellElement == null)
                {
                    throw new Exception("Cannot get cell element");
                }
      
                return cellElement;
            }

    I hope this helps. Let me know if you have any other questions.

    Kind regards,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready