I used e.Worksheet.Table.Columns.Remove(3) under ExcelMLExportRowCreated but doesn't work.
I can't make the TagID column invisible on the grid display because I need to use this TagID to check -(!list.Contains(e.Row.Cells.GetCellByName("TagID").Data.DataItem.ToString())) if this TagID exists in the grid. I have to remove it after checking its existing.
-----------------------------------------------------------------------------------
if (!list.Contains(e.Row.Cells.GetCellByName("TagID"
{
if (e.RowType == GridExportExcelMLRowType
{
Int32
e.Worksheet.Table.Rows.Remove(e.Row);
}
}
{
e.Worksheet.Table.Columns.RemoveAt(3); // want to remove TagID column for excel display but not working
}
Please help!
5 Answers, 1 is accepted
I don't recommend that you go this route. Instead, you can hide the column before starting the export as demonstrated in the code-snippet below:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.GetColumn(
"ColumnName"
).Visible =
false
;
RadGrid1.MasterTableView.ExportToExcel();
}
Please note that this change will be visible in the exported file only.
ExcelML basics
Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Thanks for your reply.
I can not hide the column (TagID) before export to excel, because I need to use this column in the
ExcelMLExportRowCreated to checking if the TagID is checked, if it is not checked, this row needs to be removed.
So this have to happen after calling MasterTableView.ExportToExcel()
protected
void rgTranslationView_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs
{
if (!list.Contains(e.Row.Cells.GetCellByName("TagID"
).Data.DataItem.ToString()))
{
if (e.RowType == GridExportExcelMLRowType
.DataRow)
{Int32
i = e.Worksheet.Table.Rows.Count;
e.Worksheet.Table.Rows.Remove(e.Row); // remove row whenTagID is in the checked list
}
}
else
{
e.Worksheet.Table.Columns.RemoveAt(3); // want to remove TagID column for excel display but not working
}
}
Please advice how I can remove this column after MasterTableView.ExportToExcel().
Thanks,
Jessie
You could hide the column by setting its Hidden property to true:
protected
void
RadGrid1_ExcelMLWorkBookCreated(
object
sender, GridExcelMLWorkBookCreatedEventArgs e)
{
e.WorkBook.Worksheets[0].Table.Columns[2].Hidden =
true
;
}
ExcelML structure / GridExcelBuilder
Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
I don't see
RadGrid1_ExcelMLWorkBookCreated
evens under radgrid, only ExcelMLExportRowCreated and
ExcelMLExportStylesCreated
. I am using Q1 2010 NET35. So where should I put this piece of code?
Jessie
Please go to the following thread:
Link to public post
Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.