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
Thanks, I have tried this code:
It does pickup the color if CellValuePresenter style was set;
It does not pickup if DataAreaCellPresenter was set.
Also seems like only visible rows are exported with colors - all rows which were invisible are exported without colors.
HI,
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
Thanks, but it does not work - always getting #FFFFFFFF value.
Background is set with DataTriggers for
FieldLayoutSettings.DataRecordCellAreaStyle
Any other ideas?
I am just following up on this forum thread.
Please let me know if you require further assistance.
Sincerely, Matt Developer Support Engineer
foreach (var item in xamDataGrid.DataSource)
{
var dataRecord = xamDataGrid.GetRecordFromDataItem(item, false);
var color = dataRecord.Cells[1].DataPresenter.Background;
}