Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Error Adding Image on Export
posted

I'm trying to export a grid that has an image column to PDF.

I'm currently using the CellExporting Event to try add the image.

 protected void dExporter_CellExporting(object sender, DocumentCellExportingEventArgs e)
        {
            if (!e.IsHeaderCell && !e.IsFooterCell && !e.IsSummaryCell)
            {
                if (e.GridCell.Column.Key == "ImageUrl")
                {

                    // Remove Html Tags
                    var url = e.GridCell.Text;
                    var startPos = url.IndexOf("\"") + 1;
                    var endPos = url.LastIndexOf("\"");

                    url = url.Substring(startPos, endPos - startPos);
                    e.ReportCell.AddImage(new Infragistics.Documents.Graphics.Image(url));
                }
            }
        }

 

The issue I am having is that e.ReportCell is always null.
How do I initialize this so that I can format the ReportCell, or should I be trying to do this in a different way

Parents
  • 3147
    posted

    Hi,

    This is a bug, you can submit it to our support system.

    Currently I can suggest you to handle the RowExported event and manipulate the cell from there:

     void WebDocumentExporter1_RowExported(object sender, DocumentRowExportedEventArgs e)
     {
      if (!e.IsHeaderRow && !e.IsFooterRow && !e.IsSummaryRow)
      {
       System.Reflection.PropertyInfo property = e.ReportRow.GetType().GetProperty("Cells");
       IList cells = property.GetValue(e.ReportRow, null) as IList;

       // Get the desired cell by index
       ITableCell reportCell = cells[0] as ITableCell;

       reportCell.AddImage(new Infragistics.Documents.Graphics.Image(url));
      }
     }

    I hope that this workaround does the job for you!

Reply Children