troubleshooting Question

Crystal Reports - Export to excel (formatted output)

Avatar of Shanmugam Rajagopal
Shanmugam Rajagopal asked on
C#Crystal Reports
4 Comments2 Solutions644 ViewsLast Modified:
I am using ReportDocument object with following options to export rpt data to excel

crystalExportOptions = (ExportOptions)reportDocument.ExportOptions;

                    if (oFileType.IsExcel)
                    {
                        DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions();
                        diskOptions.DiskFileName = destinationFolder + sExportFileName;

                        ExcelFormatOptions formatOptions = new ExcelFormatOptions();
                        formatOptions.ExcelTabHasColumnHeadings = true;
                        formatOptions.ShowGridLines = true;
                        formatOptions.ExcelUseConstantColumnWidth = true;
                        formatOptions.ExcelConstantColumnWidth = 1000;
                        crystalExportOptions.ExportFormatOptions = formatOptions;
                        crystalExportOptions.ExportFormatType = ExportFormatType.ExcelRecord;
                        crystalExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                        crystalExportOptions.ExportDestinationOptions = diskOptions;
                    }

using (Stream stream = reportDocument.ExportToStream(ExportFormatType.Excel))
{
      using (MemoryStream memoryStream = new MemoryStream())
                        {

                            stream.CopyTo(memoryStream);
                           //Save to DB
                        }
                    }
}

when I retrieve from db and download the excel it looks unformatted. How to make the cells Autowidth for the column in the excel file?

Thanks for your help
ASKER CERTIFIED SOLUTION
Ido Millet
Owner, Millet Software

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros