Skip to Content
0
Former Member
Apr 01, 2009 at 10:05 AM

Alignment problem in excel when export from cr viewer

57 Views

Hello,

We are developing a windows application in VS 2005 with CR XI.

When we export the report to excel,

1. If the report has any null value, there are alignment problems.

2. The worksheet name is coming as "Sheet 1" by default. I need to change it to the name of the report.

Is there any solution to fix the above issues. Please let me know.

Code Used for export:

Private Sub cmdExport_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExport.Click

Dim StrExportPath As String

Dim diskOpts As DiskFileDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions()

Dim exportOpts As ExportOptions

Dim myExportFormatOptions As ExcelFormatOptions = ExportOptions.CreateExcelFormatOptions()

Try

Cursor.Current = Cursors.WaitCursor

cmdExport.Enabled = False

StrExportPath = txtExportPath.Text

If (StrExportPath.Length > 0) Then

If Not Strings.Right(StrExportPath.Trim().ToLower, 4) = ".xls" Then

StrExportPath = txtExportPath.Text & Strings.Left(objExportSave.Filter, 4)

End If

diskOpts.DiskFileName = StrExportPath

myExportFormatOptions.ExcelConstantColumnWidth = 300

myExportFormatOptions.ExcelUseConstantColumnWidth = True

exportOpts = New ExportOptions

exportOpts.ExportFormatOptions = myExportFormatOptions

exportOpts.ExportDestinationOptions = diskOpts

exportOpts.ExportFormatType = ExportFormatType.Excel

exportOpts.ExportDestinationType = ExportDestinationType.DiskFile

customerReport.Export(exportOpts)

'customerReport.ExportToDisk(ExportFormatType.Excel, StrExportPath)

Cursor.Current = Cursors.Arrow

'Added at Dot Net Migration To Display the message.

MsgBox("Report Exported successfully", MsgBoxStyle.Information, ModMessage.strTitle)

Else

MsgBox("Please enter a File Name to Export", MsgBoxStyle.Information, ModMessage.strTitle)

End If

Catch ex As Exception

funMsgDesc(4001, ex.Message.ToString)

Finally

Cursor.Current = Cursors.Arrow

cmdExport.Enabled = True

End Try

Thanks in advance.