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
3788
WebExcelExporter exporting hidden column Text
posted

i am using 2011.1 version

I am using WebExcelExporter  to export the grid into excel.

i have some hidden column in grid. if i export the grid into excel then

hidden column header does not export but hidden column cell values are exporting

and it override the Next cell visible column value.

This is happen only when i have atteached CellExporting event on WebExcelExporter .

and i am trying to cancel the event and i am atteching the e.worksheetcell.value to some

values. and also

i have Link column and i wanted to show it the Linktext  not <a title="some thing">

i have more then one LinkColumn in my grid for first column it work as expected

but for 2nd Lincolumn it showing the text as <a title="some thing2"> not Text alone.

why?

 

For ex if i have a grid with fallowing column

LinkColumn-1  HideColumn-1   Column-2        LinkColumn-3    Column-4

  LinValue-1         HideValue          VisibleVal2      LinkVal3               VisibleVal4

Then Grid exported Like this

LinkColumn-1  Column-2        LinkColumn-3    Column-4

 LinValue-1       HideValue          VisibleVal2         <a title=LinkVal3  />

VisibleVal4 goes out and not showing

Why  HideValues is showing?

why LinkVal3 is shoing as <a title=LinkVal3  />?

i have written the code inside the CellExporting event lnk this

private static void OnCellExporting(object sender, ExcelCellExportingEventArgs e) {
      if(!e.IsHeaderCell && !e.IsFooterCell && !e.IsSummaryCell) {      
        GridRecordItem item=_exporter.WebDataGrid.Rows[e.CurrentRowIndex - 1].Items[e.CurrentColumnIndex];
       
        if(item.Column.GetType().Name == "TemplateDataField") {
          
          TemplateDataField field = item.Column as TemplateDataField;
          if(!string.IsNullOrEmpty(((TemplateColumn)field.ItemTemplate)._linkColumnPath)) {
            System.Web.UI.HtmlControls.HtmlAnchor anchor = item.FindControl("anchor") as System.Web.UI.HtmlControls.HtmlAnchor;
            if(anchor != null) {
              e.Cancel = true;
              e.WorksheetCell.Value = anchor.Title;
              e.WorksheetCell.CellFormat.Font.Height = 200;           
            }
          }
        }
        else {
          e.Cancel = true;
          e.WorksheetCell.CellFormat.Font.Height = 200;
          e.WorksheetCell.Value = item.Text;
        }
       
      }
    }