HOME  |  NEWS  |  PRODUCTS  |  SUPPORT  |  ORDER  |  CORPORATE  
 

Tip #44 - Exporting Reports Programmatically


Category

Rave - General

Question

    I am using the enduser designer and I would like to be able to export reports from one .rav file to another. How would I do that?

Solution

    The enduser designer does not provide an Export menu item like what you will find when using rave.exe. However, Reports, global pages and dataviews can be exported fairly easily. The example that follows will export the Introduction report, the GlobalPage2 and the CustomerDV from the RaveDemo.rav file that ships with Rave.

    Delphi Example:
    uses
      RVProj, RVClass;
    
    procedure TForm1.butnExportClick(Sender: TObject);
    
    var
      I1: integer;
      MyExportList: TList;
    
    begin
      MyExportList := TList.Create;
      try
        If not RaveProject1.Active then begin
          RaveProject1.Open;
        end;
        With RaveProject1.ProjMan do begin
          If ReportList.Count > 0 then begin
            For I1 := 0 to ReportList.Count-1 do begin
              if CompareText(TRaveReport(ReportList[i1]).Name,'IntroductionReport') = 0 then begin
                MyExportList.Add(ReportList[i1]);
              end;
            end; { for }
          end; { if }
          If GlobalPageList.Count > 0 then begin
            For I1 := 0 to GlobalPageList.Count-1 do begin
              if CompareText(TRaveDataObject(GlobalPageList[i1]).Name,'GlobalPage2') = 0 then begin
                MyExportList.Add(GlobalPageList[i1]);
              end;
            end; { for }
          end; { if }
          If DataObjectList.Count > 0 then begin
            For I1 := 0 to DataObjectList.Count-1 do begin
              if CompareText(TRaveDataObject(DataObjectList[i1]).Name,'CustomerDV') = 0 then begin
                MyExportList.Add(DataObjectList[i1]);
              end;
            end; { for }
          end; { if }
          If MyExportList.Count > 0 then begin
            ExportProject('test.rav',MyExportList);
          end; { if }
        end; { with }
      finally
        FreeAndNil(MyExportList);
      end; { tryf }
    end;
    C++Builder Example:
    void __fastcall TForm1::butnExportClick(TObject *Sender)
    {
    
      int I1;
      TList* pExportList;
      TList* pRaveList;
      TRaveReport* pRaveReport;
      TRaveDataObject* pRaveDataObject;
    
      pExportList = new TList;
      try {
        if (!RaveProject1->Active) {
          RaveProject1->Open();
        }// if
        pRaveList = RaveProject1->ProjMan->ReportList;
        if (pRaveList->Count > 0) {
          for (I1 = 0; I1 < pRaveList->Count; I1++) {
            pRaveReport = (TRaveReport*)pRaveList->Items[I1];
            if (CompareText(pRaveReport->Name,"IntroductionReport") == 0) {
              pExportList->Add(pRaveReport);
            }// if
          }// for
        }// if
        pRaveList = RaveProject1->ProjMan->GlobalPageList;
        if (pRaveList->Count > 0) {
          for (I1 = 0; I1 < pRaveList->Count;I1++) {
            pRaveDataObject = (TRaveDataObject*)pRaveList->Items[I1];
            if (CompareText(pRaveDataObject->Name,"GlobalPage2") == 0) {
              pExportList->Add(pRaveDataObject);
            }// if
          }// for
        }// if
        pRaveList = RaveProject1->ProjMan->DataObjectList;
        if (pRaveList->Count > 0) {
          for (I1 = 0; I1 < pRaveList->Count; I1++) {
            pRaveDataObject = (TRaveDataObject*)pRaveList->Items[I1];
            if (CompareText(pRaveDataObject->Name,"CustomerDV") == 0) {
              pExportList->Add(pRaveDataObject);
            }// if
          }// for
        }// if
        if (pExportList->Count > 0) {
          RaveProject1->ProjMan->ExportProject("test.rav",pExportList);
        }// if
      }// try
      __finally {
        FreeAndNil(pExportList);
      }// __finally
    }// butnExportClick()

Tip created by Nevrona Designs - Email : tech@nevrona.com - Web : http://www.nevrona.com

Date Created: 1/3/2002 12:16:16 PM - Date Last Updated: 1/3/2002 1:34:01 PM