Print Page | Close Window

Page Header Bug

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3448
Printed Date: 18 May 2024 at 8:07am


Topic: Page Header Bug
Posted By: gurarpangill
Subject: Page Header Bug
Date Posted: 16 Jun 2008 at 12:15pm
We have migrated from .net 2003 to .net 2005. In .net 2005 page header  name changes to Section2(Page Header).
 
 
We are exporting report to Excel.
Problem is Page Header is not repeating for each page in .net 2.0 . But it was working fine with .net 1.1.
 
I require page header to be repeated for each page.
 
Please help its urgent and i am in fix.
 
Thanks in advance



Replies:
Posted By: BrianBischof
Date Posted: 16 Jun 2008 at 2:17pm
Unfortunately, you can't do it via the Export button. In the CR XI upgrade they have a full Options dialog box that lets you set this property.

However, you can export the report using code and programmatically set the property ExcelTabHasColumnHeadings property to true. This will force the column headings to appear on every page.

I have the full Crystal Reports object model documented in my CR.NET books. You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: gurarpangill
Date Posted: 17 Jun 2008 at 5:44am

I could not find dialog box to set property.

Can u help me. I will be really thankful.
Because i found is the expert section which supress or perform other thing on page header. But does not repeat page header.


Posted By: gurarpangill
Date Posted: 19 Jun 2008 at 7:08am
I tried option option programatically for excel . It didnt work. Please let me know some other solution.


Posted By: lockwelle
Date Posted: 22 Oct 2008 at 11:15am
I too had this issue, but finally found that what is needed is to set the value for ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage.  Setting ExcelTabHasColumnHeadings = true was not as crucial to getting the headers and footers to print in the file.


Posted By: ayix
Date Posted: 22 Aug 2010 at 10:26pm
I have a problem with header, footer, and page break when I export crystal report to excel using c#.Net. I try to use ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage and ExportPageBreaksForEachPage = true. But Ican't use it, because that two method is unknown in program. I already type:
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
What should I do now? I really need to use that two method.
Thank you for your attention


Posted By: lockwelle
Date Posted: 23 Aug 2010 at 3:26am

Imports CrystalDecisions.Shared

 

            Dim strFileName As String = String.Empty
            Dim exportOpts As New ExportOptions
            Dim diskOpts As New DiskFileDestinationOptions
            Dim excelFormatOpts As ExcelFormatOptions = ExportOptions.CreateExcelFormatOptions
            Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument = CType(Me.crvReport.ReportSource, CrystalDecisions.CrystalReports.Engine.ReportDocument)

            'stuff about the creating the excel file on the user's computer
            sfdSaveFile.DefaultExt = "xls"
            sfdSaveFile.AddExtension = True

            'If mstrDefaultFileName <> String.Empty Then
            '    sfdSaveFile.InitialDirectory = Application.StartupPath  'Default directory
            '    strFileName = sfdSaveFile.InitialDirectory & "\" & mstrDefaultFileName.Replace(" ", "") & "_" & mstrUserID & "_" & Date.Now.ToString.Replace("/", ".").Replace(":", ".")
            '    sfdSaveFile.FileName = strFileName
            'End If
            sfdSaveFile.Title = "Select a location to save the Excel File"
            sfdSaveFile.Filter = "All Files (*.*)|*.*|Excel 97-2003 (*.xls)|*.xls"
            sfdSaveFile.FilterIndex = 2
            boolCancel = (sfdSaveFile.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel)

            diskOpts.DiskFileName = sfdSaveFile.FileName
            excelFormatOpts.ExcelTabHasColumnHeadings = True
            excelFormatOpts.ExcelUseConstantColumnWidth = True          'each field in its own column--no merge
            excelFormatOpts.ExcelConstantColumnWidth = 60
            excelFormatOpts.ConvertDateValuesToString = True
            excelFormatOpts.ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage
            excelFormatOpts.ShowGridLines = True

            exportOpts.FormatOptions = excelFormatOpts
            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
            exportOpts.ExportDestinationOptions = diskOpts
            exportOpts.ExportFormatType = ExportFormatType.Excel
            exportOpts.ExportFormatOptions = excelFormatOpts

99% of this came from Brian's code on how to export to Excel that was answered in a post.


Posted By: ayix
Date Posted: 23 Aug 2010 at 3:24pm
I already write the code like this:
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

SaveFileDialog savedialog = new SaveFileDialog();
savedialog.InitialDirectory = "c:\\";
savedialog.Filter = "Excel Files (*.xls)|*.xls|All files (*.*)|*.*";
savedialog.FilterIndex = 1;
savedialog.RestoreDirectory = true;
if (savedialog.ShowDialog() == DialogResult.OK)
{
    ExportOptions exportOpts = new ExportOptions();
        DiskFileDestinationOptions DestinationOpts = new DiskFileDestinationOptions();
        DestinationOpts.DiskFileName = savedialog.FileName;
        exportOpts.ExportFormatType = ExportFormatType.Excel;
        ExcelFormatOptions exportFormatOptions = ExportOptions.CreateExcelFormatOptions();
        exportFormatOptions.ExportPageBreaksForEachPage = true;
        exportFormatOptions.ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage;

        exportFormatOptions.ExcelAreaType = AreaSectionKind.WholeReport;
        exportFormatOptions.ExcelUseConstantColumnWidth = false;
        exportOpts.ExportFormatOptions = exportFormatOptions;
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOpts.ExportDestinationOptions = DestinationOpts;
        report3.Export(exportOpts);
}

I already type using CrystalDecisions.Shared, but the method for the bold text still not recognize. Is there  any wrong code in my code? or maybe I forget something?


Posted By: BrianBischof
Date Posted: 23 Aug 2010 at 8:44pm
Where did you get this code?

exportFormatOptions.ExportPageBreaksForEachPage = true;
exportFormatOptions.ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage;

I don't have it in my book, nor do I see it in the object model.



-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: ayix
Date Posted: 23 Aug 2010 at 8:58pm
I get this code from http://msdn.microsoft.com/en-us/library/ms226409(v=VS.90).aspx
Beside that code, is there any other way for me to export crystal report to excel with the header, footer, and also page break just like in crystal report?


Posted By: lockwelle
Date Posted: 25 Aug 2010 at 5:09am
I don't remember where I found the code, but it has been running at my company for the better part of 2 years.
 
I remember that most of what I found, I found in a post that Brian made about exporting to Excel.  It might have been about column sizing, but it has obviously been around 2 years ago when I found it, and it was older than that...I think.
 
Sorry I can't be more helpful.



Print Page | Close Window