Excel Export - Web Report without

Hi,

I have tried different things for Excel Export to avoid page breaks or do not repeat Column Headers. After using WebReport.XlsxSeamless = true, system not printing Page Header and page footers are not printing but other Headers or group headers are still printing. Is there anyway to avoid printing Column Headers or Group header on each page in Excel Export.

Thanks.
devoas

Comments

  • edited February 2017
    Set height = 0;
    using (FastReport.Report rpt = new FastReport.Report())
    {                                        
        rpt.Load(HttpContext.Current.Server.MapPath("~/App_Data/rptLdg.frx"));
        rpt.RegisterData(dt, dt.TableName);
        foreach (FastReport.Base obj in rpt.AllObjects)
        {
            Type type = obj.GetType();
            if (type == typeof(FastReport.GroupHeaderBand) | type == typeof(FastReport.GroupFooterBand))
            {
                FastReport.BandBase band = obj as FastReport.BandBase;
                band.Height = 0F;
            }
        }
        rpt.Prepare();
        using (FastReport.Export.OoXML.Excel2007Export xl = new FastReport.Export.OoXML.Excel2007Export())
        {
            xl.Export(rpt, @"d:\test.xlsx");
        }
    }
    
  • edited 3:35PM
    Thanks alot for your detailed reply. Following points need more assistance, as we are creating excel outputs from Web Viewer,

    1. How I can bind the given code on Web Viewer Export/Save options/buttons. Are you suggesting to create another button and write this Code.
    2. Taking your code will not print first occurrence of these group headers. Which is not required. Basically I want these headers not repeat on each page. Normally for Printing and viewing purpose we set Column headers / group headers to appear on each page, but on excel export this is creating problem.
    3. Even after removing headers, Fast Report create some space between pages, rather than continuous rows of data.

    So you valuable suggestion is required on this.
  • edited February 2017
    wrote:
    1. How I can bind the given code on Web Viewer Export/Save options/buttons. Are you suggesting to create another button and write this Code.
    yes, create another button and assign a function, you can place that button into built-in toolbar by injecting html tags with jquery, see attached picture.
    $(".frtoolbar").append('<div>[img]/content/smiley.png" onclick="alert(\'Hello World\')" height="32"></div>');
    
    wrote:
    2. Taking your code will not print first occurrence of these group headers. Which is not required. Basically I want these headers not repeat on each page. Normally for Printing and viewing purpose we set Column headers / group headers to appear on each page, but on excel export this is creating problem.
    3. Even after removing headers, Fast Report create some space between pages, rather than continuous rows of data.

    i tried to delete object inside header/footer but it still showed out blank row with a smaller height. you may delete header/footer band, but.... in my case, i can't delete because contains a script beneath header band.
    using (FastReport.Report rpt = new FastReport.Report())
    {
        rpt.Load(HttpContext.Current.Server.MapPath("~/App_Data/cf.frx"));
        rpt.RegisterData(dt, dt.TableName);
        foreach (FastReport.Base obj in rpt.AllObjects)
        {
            Type type = obj.GetType();
            if (type == typeof(FastReport.GroupHeaderBand) | type == typeof(FastReport.GroupFooterBand))
            {
                FastReport.BandBase band = obj as FastReport.BandBase;
                band.Height = 0;
            }
            if (type == typeof(FastReport.TextObject))
            {
                FastReport.TextObject text = obj as FastReport.TextObject;
                if (text.HasRestriction(FastReport.Restrictions.DontMove))
                {
                    text.Delete();
                }
            }
        }
        rpt.Prepare();
        using (FastReport.Export.OoXML.Excel2007Export xl = new FastReport.Export.OoXML.Excel2007Export())
        {
            xl.Export(rpt, @"d:\test.xlsx");
        }
    }
    
  • edited 3:35PM
    Can you tell me how to set UnlimitedPageHeight in FastReport.Report rpt object . This is mentioned in document but cannot find the exact property where to set. I want to set it before generating excel file. So may be I have to do nothing related to different objects.

  • edited 3:35PM
    FastReport.Report report = new FastReport.Report();
    FastReport.ReportPage reportPage = report.Pages[0] as FastReport.ReportPage;
    reportPage.UnlimitedHeight = true;
    
  • edited 3:35PM
    ipong wrote: »
    FastReport.Report report = new FastReport.Report();
    FastReport.ReportPage reportPage = report.Pages[0] as FastReport.ReportPage;
    reportPage.UnlimitedHeight = true;
    

    This is working properly and export files without page breaks. Its a better choice for this purpose.

    Is there any possibility or Event that we can call before Web viewers standard Export/File Save Button and set this value of Page height unlimited and after save finished restore the standard page value.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.