I am trying to export XamDataGrid to excel.
Question: how do I export format settings?
Let's say I have one column showing currency and another showing percentage.
Both are double values. I need it exported to excel with number formatting.
Is it possible to do?
Is it possible to access somehow cell's ValueEditor.Format property from the code?
Another problem:
I am setting bacground property of DataRecordCellAreaStyle at runtime.
The style has datatriggers and depending on particular field value it sets row background color.
Now I want to export that color to excel as well. I can't find the way to read that color from the cell or row...
Thanks
Hi Dierk,
did you downloaded XAM Feature Browser? There is a sample in xamDataGrid->Excel Exporter called Custom Cell Styling. I think this sample will answer most of your questions.
You can apply any formatting using the "FormatString" property of the igExcelExporter:FormatSettings
Thanks, but this is not what my question was about.
My question was how to read the cells/rows background brush from the grid?
Once I know the color, then I can use FormatString to pass that color. But I need to know that color first.
foreach (var item in xamDataGrid.DataSource)
{
var dataRecord = xamDataGrid.GetRecordFromDataItem(item, false);
var color = dataRecord.Cells[1].DataPresenter.Background;
}
HI,
I am just following up on this forum thread.
Please let me know if you require further assistance.
Sincerely, Matt Developer Support Engineer
Thanks, but it does not work - always getting #FFFFFFFF value.
Background is set with DataTriggers for
FieldLayoutSettings.DataRecordCellAreaStyle
Any other ideas?
Try this code
foreach (var item in xamDataGrid1.DataSource) {
var Record = xamDataGrid1.GetRecordFromDataItem(item, false);//
DataRecord dr = Record as DataRecord;
foreach (Cell c in dr.Cells) { CellValuePresenter cvp1 = CellValuePresenter.FromRecordAndField(dr, c.Field); if (cvp1 != null) { var color = cvp1.Background; } } Sincerely, Matt Developer Support Engineer
Here a post with a sample that should resolve your issue:
http://ko.infragistics.com/community/forums/p/72531/367075.aspx
Hi Infragistics Team,
I have a similar situation where I need to preserve the color-coding on exporting to excel.
The color-coding is dynamic and here's how it is done:
dr.Cells["Column1"].EditorStyle = xamDataGrid1.TryFindResource("BackColorRedTextStyle") as Style;
I did look at the sample in XamFeatureBrowser, but it is being set at design time and not run time. So, not much of help.
I used the sample code snippet above to loop through the DataRecords and Cells to retrieve the Style and corresponding Setters.
But I am at a loss later on how to set the FormatString to preserve the style. Any sample code would be highly helpful.
Thanks.
Thanks. Might have some questions later on.
I am following up on this forum thread.
Do you need further assistance regarding this issue?.
The colors of the non viewable cells are not populated due to Cell Vitualization. You would have to get the styles that would be applied and calculate what the colors for each cell would be if they were inview, inorder to find the colors. Here a help link on Virtualizationhttp://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamData_Performance_Optimizations_Overview.html