Hi,
i export data from a DataGrid to an excel file, with TableView.ExportToXlsx(string filePath). Date fields are exported OK.
In some szenarios i modify the column sequence befor exporting. Text fields are exported without line breaks, that is OK. But date fields are now exported as Text (for example 40932 as 24.01.2012). I tried a lot, but nothing helps. Can you help?
// Geändert durch [CHANGE_USER] (NUR LESEND)
GridControlMain.Columns["CHANGE_USER"].Header = PropertyClass.CustomsData_Column_O;
GridControlMain.Columns["CHANGE_USER"].Visible = true;
GridControlMain.Columns["CHANGE_USER"].VisibleIndex = 36;
GridControlMain.Columns["CHANGE_USER"].PrintCellStyle = (System.Windows.Style)Application.Current.Resources["noLineBreaksText"];
GridControlMain.Columns["CHANGE_USER"].GroupIndex = -1;
// Geändert am [CHANGE_DATE] (NUR LESEND)
GridControlMain.Columns["CHANGE_DATE"].Header = PropertyClass.CustomsData_Column_O;
GridControlMain.Columns["CHANGE_DATE"].Visible = true;
GridControlMain.Columns["CHANGE_DATE"].VisibleIndex = 37;
//GridControlMain.Columns["CHANGE_DATE"].PrintCellStyle = (System.Windows.Style)Application.Current.Resources["noLineBreaksText"];
GridControlMain.Columns["CHANGE_DATE"].GroupIndex = -1;
<Style x:Key="noLineBreaksText" TargetType="dxe:TextEdit" BasedOn="{StaticResource {dxgt:TableViewThemeKey ResourceKey=DefaultPrintCellStyle}}">
<Setter Property="IsPrintingMode" Value="True" />
<Setter Property="dxp:ExportSettings.TargetType" Value="Text" />
<!-- <Setter Property="dxp:TextExportSettings.Text" Value="{Binding Value, Converter={local:RemoveLineBreaksConverter}}" /> -->
<Setter Property="MaxHeight" Value="22" />
</Style>
Thank you very much
Andreas
Hi Andreas,
Your scenario is not entirely clear to me. Would you please specify what version of our controls you are using? In v15.1, the ExportToXlsx method works in ExportType.DataAware mode by default and should not apply a custom PrintCellStyle until you are enable the old ExportType.WYSIWYG mode.
Hi Alexander, i must check that. I use ExportToXlsx(). It is an program version from earlier DevExpress versions and updated to 15.1.8, it works, there are no errors. If i comment out then PrintCellStyle the date fields are not in date format. How can i set the excel cell format to date with DataAware or other possibilities? If i use only ExportToXlsx() without modify the column sequence, the date fields exported as date. Thank you very much.
Hello,
I've tried to reproduce the issue, but my attempt was not successful. Event if I change columns' sequence, a date field is exported as it should. I've attached a simple sample and screencast. Would you please modify my sample project to demonstrate the issue?
Thanks,
Kirill
Hi Kirill, do you have the sample in 15.1.8? Before chaning columns sequence i hide all columns in the grid control.
// Set all columns to hidden
foreach (GridColumn col in DataGridContent.GridControlMain.Columns)
{
col.Visible = false;
}
Hi Andreas,
Please see the sample converted to version 15.1.8 in the attachment. I've tried hiding columns there as you suggested, but date values are still exported as expected. Am I missing anything?
Thanks,
Alex
Hi Alexander i have modified your sample. If i use the export options. If the background is set for column CHANGE_DATE, the formatting is lost and the date is exported in number format. See modified sample.
view1.ExportToXlsx("new.xlsx", op);
void op_CustomizeCell(DevExpress.Export.CustomizeCellEventArgs ea)
{
if (ea.ColumnFieldName == "CHANGE_DATE")
{
ea.Formatting.BackColor = System.Drawing.Color.Orange;
ea.Handled = true;
}
}
Hi Andreas,
I've successfully reproduced the issue on my side and passed this ticket to our developers for further research. We'll update this thread as soon as we make any progress.
Regards,
Nadya
Hi Nadya, thank you very much. Can you send me a small sample ExportToXlsx method with ExportType.DataAware and WYSIWYG to see the difference?
Hi Andreas,
Sure. I've modified your sample.You can find it in attachment.
Feel free to contact us if you need further assistance.
Regards,
Nadya