Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
920
Exporting to excel - Cell formats
posted

I need to export the same format as what I display. I am wiring up the CellExportingEvent. I am not sure how I should translate the formats in this event.

<igDp:Field HorizontalContentAlignment="Right" Format="G4" .../>
<igDp:Field HorizontalContentAlignment="Right" Format="F2" .../>

To keep the formats in the UI and this event consistent, I tried binding the Format property to a string on the UI and use the same string in the event. But it is not working. How can I do this?

public string FormatF2
{
get{return "F2";}
}

<igDp:Field HorizontalContentAlignment="Right" Format="{Binding FormatF2"} Name="score".../>


protected override void FormatCell(object sender, CellExportingEventArgs e)
{
switch (e.Field.Name)
{
case "score":
e.FormatSettings.FormatString = FormatF2; // This does not work

// e.FormatSettings.FormatString = e.Field.Format // This does not work either
break;
}
}