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
Our community of experts have been thoroughly vetted for their expertise and industry experience.