Hi Team,
I have a radgrid which I want to export to Excel.
Columns and data in my grid, both are left aligned (please find attached images.)
But when I export the grid to excel, headers align center whereas data align left or right.
I tried with ExcelExportCellFormatting event, but got no success.
Here is my code :
and on button click event :
Please find attached the images of my grid and report.
Could you please help me out ??
Regards,
Lok..
I have a radgrid which I want to export to Excel.
Columns and data in my grid, both are left aligned (please find attached images.)
But when I export the grid to excel, headers align center whereas data align left or right.
I tried with ExcelExportCellFormatting event, but got no success.
Here is my code :
protected void rgContracts_ExcelExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e) { try { GridDataItem item = e.Cell.Parent as GridDataItem; if (e.FormattedColumn.UniqueName == "ContractNo") e.Cell.Style["Horizontal-Align"] = "Right"; if (item.ItemType == GridItemType.Item) item.Style["Horizontal-Align"] = "Left"; if (item.ItemType == GridItemType.Header) e.Cell.Style["Horizontal-Align"] = "Right"; } catch (Exception ex) { XITingExceptionProcessor.ProcessException(this, ex); } }and on button click event :
protected void btnReport_Click(object sender, EventArgs e) { try { foreach (GridColumn item in rgContracts.MasterTableView.Columns) { if ((item.UniqueName == "TemplateColumn_Select")) item.Visible = false; if(item.UniqueName=="Details") item.Visible=false; } rgContracts.AllowSorting = false; rgContracts.AllowFilteringByColumn = false; rgContracts.ExportSettings.IgnorePaging = true; rgContracts.ExportSettings.OpenInNewWindow = true; rgContracts.ExportSettings.ExportOnlyData = true; rgContracts.MasterTableView.ExportToExcel(); } catch (Exception ex) { XITingExceptionProcessor.ProcessException(this, ex); } }Please find attached the images of my grid and report.
Could you please help me out ??
Regards,
Lok..
