I have formatted couple of Columns within the XAMDataGrid using the following Feature
<Style TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="Mask" Value="nnn,nnn,nnn,nnn.nn"/> <Setter Property="NullText" Value="-" /> </Style>
However when I export the Grid to Excel, the formatting of number is lost for e.g. the comma's go missing. Also huge numbers like 150000000000 are displayed as 1.5E+11. Numbers with decimal places as XXX.00 are displayed as XXX. When we manually change the format on the excelsheet to number, the value displayed is as desired.
I am not able to manually export each row and each column as the Grid might have grouping which we wish to have in the same format while export to excel.
Can you please help me with this?
Thanks, it does answer the question; but implementation is very messy!
I thought I could create a generic export function across my application (containing about 30+ grids) and throw any grid to it and it sorts the export functionality but looking at your sample; I have to create 30 different export function to incorporate individual converters as well the 30 odd objects which are bound to those grid.
Is there any further recommendation?
Hi Abbas,
Attached you can find the sample demonstrating manually exporting styles with triggers to excel. I have played with it to make exported the triggers base on the cell condition. Please let me know if you have any furthered questions.
I am attaching your sample with data triggers and see the problem when styles based on data triggers are not exported.
Just tried a grid with data trigger and it does not bring styles based on triggers in excel.
The sample should work for triggers too, just add a trigger. If your trigger set some value to the setter and reflect on your cell style. When you export it the sample is retrieving the setter value so it should take current value of the cell setter and should be exported to excel with the current cell style.
Please let me know if this is working for you or if you have any furthered questions.