Click here to Skip to main content
15,881,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a button click that attempts to export a DevExpress pivot grid to an excel file however when you open the file in excel or google sheets it zeroes some of the data in the 'Start Time' and 'End Time' cells. Here is the c# code:

C#
private void button_Export_Click(object sender, EventArgs e)
        {            
            var x = new DevExpress.XtraPrintingLinks.CompositeLink();

            if (xtraTabControl1.SelectedTabPage == xtraTabPage_Grid)
            {
                if (saveFileDialog_Report.ShowDialog() == DialogResult.OK)
                {
                    XlsxExportOptionsEx ExportOptions = new XlsxExportOptionsEx();
                    ExportOptions.ExportType = DevExpress.Export.ExportType.WYSIWYG;

                    if (saveFileDialog_Report.FileName.ToLower().EndsWith("xlsx"))
                    {
                        try
                        {
                            pivotGridControl1.ExportToXlsx(saveFileDialog_Report.FileName, ExportOptions);
                        }
                        catch (Exception Ex)
                        {
                            cGlobal.ShowErrorMessage(Ex.Message, "Error");

                        }
                    }


                    if (saveFileDialog_Report.FileName.ToLower().EndsWith("pdf"))
                    {
                        pivotGridControl1.ExportToPdf(saveFileDialog_Report.FileName);
                    }
                }
            }
            else
                cGlobal.ShowInfoMessage("To export a chart please use the print option and then use the export feature within the preview window", "Not Available");
        }   


The data is displayed correctly in the pivot grid for example:

Start Time	End Time
07:15	     17:00
07:09	     17:00


But then one row will be randomly zeroed in excel/ sheets:

Start Time	End Time
07:15	    17:00
00:00	    00:00


What I have tried:

I've tried exporting it to XLS and it still zeroes the same rows. I can export it to CSV and it doesn't zero any rows however it doesn't look very presentable in Excel.
Posted
Updated 8-May-22 3:50am
Comments
[no name] 2-May-22 12:35pm    
Since it's a DevExpress "export", it's a DevExpress issue. If you can't find the "option", you will need to delete the "zero rows" from the file that is exported. So, ReadAllLines, etc, WriteAllLines.

1 solution

Check out original documentation: Exporting | WinForms Controls | DevExpress Documentation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900