Empty Report Export

edoedo
edited 9:09AM in FastReport VCL 5
Hello,

I have a report with two bands and i am trying to export XLSX.

First band is Report Title or ColumnHeader (storing constant column descriptions)

Second band is Master Data (showing data)

Dataset selected for Master Data band and if there is not any data report export only report title -but i do not want a report in this case-, if i set report.engineoptions.printifempty to false in this case i am getting "List index out of bounds (0)" error?

If i try to xls export after setting report.engineoptions.printifempty to false then i'm getting "Invalid variant operation" error.

Comments

  • edoedo
    edited 9:09AM
    Error comes from frxExportXLSX.pas file:
    { First default border }
      style := FMatrix.GetStyleById(0);
    
  • gordkgordk St.Catherines On. Canada.
    edited 9:09AM
    i assume that you are running and exporting the report from code correct?
    if so then show the code where you are loading and running the report and
    setting up the export filter.
  • edoedo
    edited 9:09AM
    fds_Report := TfrxDBDataset.Create(nil);
    fr_Report.EngineOptions.PrintIfEmpty := False;
    
    fds_Report.UserName := 'Report Data';
    fr_Report := TfrxReport.Create(nil);
    fr_Report.EngineOptions.DestroyForms := False;
    fr_Report.EngineOptions.SilentMode := True;
    fr_Report.EngineOptions.UseGlobalDataSetList := False;
    fr_Report.EnabledDataSets.Clear;
    
    fds_Report.DataSet := O_Report;
    //fr_Report.DataSets.Add(fds_Report);
    fr_Report.EnabledDataSets.Add(fds_Report);
    
    fr_Report.LoadFromStream(myStream2);
    fe_Excel := TfrxXLSXExport.Create(nil);
    l_file_name := l_file_name + '.xlsx';
    fe_Excel.EmptyLines := False;
    fe_Excel.ExportPageBreaks := False;
    
    fe_Excel.ShowDialog := False;
    fe_Excel.ShowProgress := False;
    
    if fr_Report.PrepareReport then
    begin
    	fe_Excel.FileName:= l_file_name;
    	if fr_Report.Export(fe_Excel) then
    	begin
    		Log_P(slInformation, 'File: "'+l_file_name+'" created succesfully.' + fr_Report.Errors.Text, L_App_Run_Nr, I_Log_Sort_Nr, I_Task_ID, I_Thread_Id);
    	end
    	else
    	begin
    		l_file_name := '';
    		Log_P(slError, 'File not created. ' + fr_Report.Errors.Text, L_App_Run_Nr, I_Log_Sort_Nr, I_Task_ID, I_Thread_Id);
    	end;
    end;
    
  • gordkgordk St.Catherines On. Canada.
    edited 9:09AM
    I would check your datasets record count befor calling before calling prepare report and exporting
  • edoedo
    edited 9:09AM
    Dataset(s) are also dynamic and i can't know which dataset should be check (there may be more than one dataset). It's related with design.
  • gpigpi
    edited 9:09AM
    Check TfrxReport.PreviewPages.Count after preparing of report
  • edoedo
    edited 9:09AM
    Yes it works. Thanks

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.