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; } } }
i have resolved the problem.
i am handling the cellexporting event diffrently, when grid some column are not visible.
For example
private
text) {
i = _weDataGrid.Columns.Count - 1; i >= 0; i--) {
(_weDataGrid.Columns[i].Header.Text == text)
i;
}
0;
e) {
(!e.IsHeaderCell && !e.IsFooterCell && !e.IsSummaryCell) {
.ToString(e.Worksheet.Rows[0].Cells[e.CurrentColumnIndex].Value));
item = WebDataGrid.Rows[e.CurrentRowIndex - 1].Items[index];
) {
;
)field.ItemTemplate)._linkColumnPath)) {
System.Web.UI.HtmlControls.
e.WorksheetCell.Value = anchor.Title;
e.WorksheetCell.CellFormat.Font.Height = 200;
e.Cancel =
{
e.WorksheetCell.Value = item.Text;
Hello Mypost,
Thank you for posting your solution for this question in our forum.
Inform me if you need additional assistance.