8 Answers, 1 is accepted
Hello ,
You can find solution for your question in the following community threads:
http://www.telerik.com/forums/hide-columns-before-export-to-excel
http://www.telerik.com/forums/export-to-excel-hidden-columns
http://www.telerik.com/forums/radgrid--can-t-remove-column-from-excel-export---please-help
Regards,Rumen
Telerik by Progress
Thx,
My project's constraint about Excel export change, now I export in Xlsx format. But I didn't find how I can catch the created workbook like "OnExcelMLWorkBookCreated" to hide column in my excel file.
Jordan.
Hello Jordan,
If you set property of the column to false, it won't be exported.
Another way is to handle the ItemCommand event and to hide the column by setting Visible=false. After the grid should be and you have to call ExportToExcel().
If your scenario is other please provide more detail about it.
Regards,Rumen
Telerik by Progress
Hi Rumen,
i don't have issue to hide a column in radgrid, I need to get the hidden column in my excel file but with a width of 0 (hide)
If I set my column to exportable = true / display = false , I still don't have the column. I think I must change de width of the excell column instead of trying to auto hide it.
I found that I can do that by doing something like this : Worksheet.get_Range("C:C", missing).EntireColumn.Hidden = true
How can I have access to the workbook before it was exported?
With the folling code I can do some style/format manipulation
protected
void
RadGridEdit_InfrastructureExporting(
object
sender, GridInfrastructureExportingEventArgs e)
{
DateTime dateValue;
e.ExportStructure.Tables[0].Style.Font.Size = FontUnit.Point(8);
foreach
(Telerik.Web.UI.ExportInfrastructure.Row row
in
e.ExportStructure.Tables[0].Rows)
{
foreach
(Telerik.Web.UI.ExportInfrastructure.Cell cell
in
row.Cells)
{
if
(DateTime.TryParse(cell.Text,
out
dateValue))
{
cell.Format = @
"mm/dd/yyyy hh:mm:ss AM/PM"
;
cell.Value = dateValue.ToString();
}
}
}
}
I tried to do something like this :
foreach
(Telerik.Web.UI.ExportInfrastructure.Column col
in
e.ExportStructure.Tables[0].Columns)
{
col.Width = 0;
}
But nothing change
Hello ,
If you'd like to hide a column in Excel, you could try to generate the excel file with RadSpreadProcessing and hide the column with its hidden property.
Regards,Rumen
Telerik by Progress
Hello Rumen,
Unfortunatly, my team leader still want to use the default excel generator of the grid. I found a way by setting the width of the GridColumn with 1px value (0 hide it ...).
I have a new issue with the excel file:
I change the font size: ExportStructure.Tables[0].Style.Font.Size = FontUnit.Point(8);
But in my excel file the font is 7.95 (why?). How can I set it to 8?
Thx,
Bouyez.