I've tried putting code right after I call grid.MasterTable.ExportToExcel() which will perform this update, but the excel spreadsheet has the 'new' last export date instead of the old one. I've tried putting code into the OnExcelMLExportRowCreated, but that's not doing what I want either. we've also looked at the gridExporting event to try and get it to happen after the export actually gets the data from the database - but the ExportToExcel method seems to get data after this occurs as well.
So is there a way I can accomplish this (say a GridExported event) that I am just missing?
5 Answers, 1 is accepted
I am not sure about the algorithm you use to calculate the last exported date in this case, however you can intercept the OnGridExporting event which is fired right before the data is processed to Excel in order to determine the export date and place it as part of the Caption property of the master table to be included in the exported file.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am not sure whether I understand your scenario completely. Can you please more detailed description about each step you followed during the export and the results from them? This will help me provide more to-the-point explanation/solution. Thank you.
Kind regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
protected void ExportData(object sender, EventArgs e) |
{ |
foreach (GridColumn _col in gridRequests.MasterTableView.Columns) |
_col.Display = true; |
switch (((LinkButton)sender).CommandArgument.ToString()) |
{ |
case "PDF": |
gridRequests.MasterTableView.ExportToPdf(); |
break; |
case "Excel": |
gridRequests.ExportSettings.Excel.Format = GridExcelExportFormat.Html; |
gridRequests.MasterTableView.ExportToExcel(); |
break; |
} |
Budget.Requests _req = new Budget.Requests(); |
System.Data.DataView _update = _req.GetWingateExport().DefaultView; |
_update.RowFilter = gridRequests.MasterTableView.FilterExpression; |
foreach (System.Data.DataRow _row in _update.ToTable().Rows) |
{ |
Budget.Requests.UpdateExportDate(Convert.ToInt32(_row["BudgetRequestID"].ToString())); |
} |
} |
For example, if I have 2 rows of data in the filtered grid and it's currently October 25, 2009 10:01AM. The last export date for these 2 rows was October 15, 2009 9:00AM I would expect the following:
DataID Name ExportDate
1 Testing 2009-15-10 9:00
2 Testing 2 2009-15-10 9:00
instead I get
DataID Name ExportDate
1 Testing 2009-25-10 10:00
2 Testing 2 2009-25-10 10:00
Hello Joe,
Thank you for the detailed explanation. Now I think I understand what you mean.
Can you please check whether the last exported date in the Excel document is reflected as expected if you invoke the UpdateExportDate method from within the OnPreRenderComplete handler of the page? Since the grid is rebound after the LinkButton click event handler and before the export operation takes place, the update should happen after that in order to keep the last exported date in the exported file.
Kind regards,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.