ActiveReports 18 .NET Edition
MESCIUS.ActiveReports.Design.Win Assembly / GrapeCity.ActiveReports.Design Namespace / Designer Class / SaveReport Method / SaveReport(FileInfo) Method
Specifies the File object to contain the report layout.
Example

In This Topic
    SaveReport(FileInfo) Method
    In This Topic
    Saves a report layout as an XML file to the specified file name.
    Syntax
    'Declaration
     
    Public Overloads Sub SaveReport( _
       ByVal file As FileInfo _
    ) 
    public void SaveReport( 
       FileInfo file
    )

    Parameters

    file
    Specifies the File object to contain the report layout.
    Example
    /// <summary>
    /// SaveReportFile - opens the Save File Dialog to save the report out to an rpx file
    /// </summary>
    private void SaveReportFile()
    {
        //If the Report was saved once, we already have a valid path, call Save on it.
        if(this._alreadySaved)
        {
            this.ardMain.SaveReport(this._savedPath);
        }
        else
        {
            //Open Save dialog to retrieve a file and path to save to
            this.dlgSaveFile.Filter = "ActiveReport Report Design (RPX) (*.rpx)|*.rpx";
            this.dlgSaveFile.FileName = "Report.rpx";
            this.dlgSaveFile.FilterIndex = 2;
            this.dlgSaveFile.RestoreDirectory = true ;
            this.dlgSaveFile.DefaultExt = ".rpx";
        
            if(dlgSaveFile.ShowDialog() == DialogResult.OK)
            {
                //Add new saved report to the recent documents cache
                if(System.IO.File.Exists(Application.StartupPath + @"\Settings\recent.xml"))
                {
                    DataSet _reportsDS = new DataSet();
                    _reportsDS.Locale = CultureInfo.InvariantCulture;
                    _reportsDS.ReadXml(Application.StartupPath + @"\Settings\recent.xml");
                    DataTable _reportsTable = _reportsDS.Tables["Reports"];
                    _reportsTable.Locale = CultureInfo.InvariantCulture;
    
                    //Create a Row
                    DataRow _rowReports = _reportsTable.NewRow();
                    object [] _myArray = new object[2];
                    this._savedPath = this.dlgSaveFile.FileName;
                    _myArray[0] = this.dlgSaveFile.FileName;
                    _myArray[1] = System.DateTime.Now;
                    _rowReports.ItemArray = _myArray;
                    _reportsTable.Rows.Add(_rowReports);
                    _reportsDS.WriteXml(Application.StartupPath + @"\Settings\recent.xml", XmlWriteMode.WriteSchema);
                }
                this.ardMain.SaveReport(this._savedPath);
            }
        }
    }
    'SaveReportFile - opens the Save File Dialog to save the report out to an rpx file
    Private Sub SaveReportFile()
        'If the Report was saved once, we already have a valid path, call Save on it.
        If Me._alreadySaved Then
            Me.ardMain.SaveReport(Me._savedPath)
        Else
            'Open Save dialog to retrieve a file and path to save to
            Me.dlgSaveFile.Filter = "ActiveReport Report Design (RPX) (*.rpx)|*.rpx"
            Me.dlgSaveFile.FileName = "Report.rpx"
            Me.dlgSaveFile.FilterIndex = 2
            Me.dlgSaveFile.RestoreDirectory = True
            Me.dlgSaveFile.DefaultExt = ".rpx"
    
            If dlgSaveFile.ShowDialog() = DialogResult.OK Then
                'Add new saved report to the recent documents cache
                If System.IO.File.Exists((Application.StartupPath + "\Settings\recent.xml")) Then
                    Dim _reportsDS As New DataSet()
                    _reportsDS.Locale = CultureInfo.InvariantCulture
                    _reportsDS.ReadXml((Application.StartupPath + "\Settings\recent.xml"))
                    Dim _reportsTable As DataTable = _reportsDS.Tables("Reports")
                    _reportsTable.Locale = CultureInfo.InvariantCulture
    
                    'Create a Row
                    Dim _rowReports As DataRow = _reportsTable.NewRow()
                    Dim _myArray(1) As Object
                    Me._savedPath = Me.dlgSaveFile.FileName
                    _myArray(0) = Me.dlgSaveFile.FileName
                    _myArray(1) = System.DateTime.Now
                    _rowReports.ItemArray = _myArray
                    _reportsTable.Rows.Add(_rowReports)
                    _reportsDS.WriteXml(Application.StartupPath + "\Settings\recent.xml", XmlWriteMode.WriteSchema)
                End If
                Me.ardMain.SaveReport(Me._savedPath)
            End If
        End If
    End Sub 'SaveReportFile
    See Also