I used code list bellow to export cr to excel. The problem is the alignment of detail in each column did not match with column header. In report design view, they are all match. Is there any way to fix it?
ExpOptions.ExportFormatType = ExportFormatType.Excel
ExpOptions.FormatOptions = New ExcelFormatOptions
Dim req As New ExportRequestContext
req.ExportInfo = ExpOptions
'Dim s As Stream
's = Rpt.FormatEngine.ExportToStream(req)
Dim strExportFile, strFileId As String
strFileId = HttpContext.Current.Session.SessionID & "_" & Replace(FormatDateTime(Now, DateFormat.ShortTime), ":", "") & ".xls"
Dim s As System.IO.MemoryStream = Rpt.ExportToStream(ExportFormatType.Excel)
.ContentType = "application/xls"
.AddHeader("Content-Disposition", "inline; filename=" & strFileId)
This is an issue with Excel, not Crystal. By default, Excel aligns numeric columns to the right, and text columns to the left. I don't think there's an option in CR .NET to change this.
You could try right-aligning your headers, or adding a double-quote (") to the beginning of the header title, which is an old shorthand way of telling Excel to right-align the column. Or, you could prepend a single-quote (') to the beginning of your numberic fields, and have them left-aligned.
If my post is your answer, please mark it as the answer. It will bring good karma.