Folder destination for reports

edited May 2011 in FastReport .NET
Hello Everyone!

I am trying to set default folder for gerenated reports (pdf, ...).

Anyone have idea how can I do it? (using programably runned reports, with using report.Show() )

Comments

  • edited 11:55PM
    Anyone has any idea? or maybe it is not possible in FP?
  • edited 11:55PM
    Hello,

    I have a little idea. You can set folder destination for reports by this way:
    Report report = new Report();
    string FolderDestinationForReports = @"C:\Users\Guest\Documents\Exported Reports\";
    FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
    report.Load(@"C:\Users\Guest\Documents\Reports\Report1.frx");
    report.Prepare();
    report.Export(export, FolderDestinationForReports + "Report1.pdf");
    report.Load(@"C:\Users\Guest\Documents\Reports\Report2.frx");
    report.Prepare();
    report.Export(export, FolderDestinationForReports + "Report2.pdf");
    
  • edited 11:55PM
    Thank you OlegK for that,

    but I am using method, which can show (generate) report,
    after that user can choose: pdf, xls, ... and then save it...

    I want just that user will not need to select folder to save file
    (can change, but default he will be directed to his default folder).

    I do not generate for example pdf files, I allow user to choose format he needs...
    public void makeReport(string _name,bool _design)
            {            
                using (FastReport.Report report = new FastReport.Report())
                {
                    string pathFolder = AppDomain.CurrentDomain.BaseDirectory + @"\reports\";
                    report.Load(pathFolder + _name + ".frx");
                    report.RegisterData(dsGlobal, _name); // System.Data.DataSet
                    
                    string frcs = "XsdFile =" +pathFolder + _name + ".xsd";
                    frcs += ";XmlFile=" + pathFolder+ _name + ".xml";
    
                    report.Dictionary.Connections[0].ConnectionString = frcs;
    
                    foreach (var item in parametersList)   // sending parameters
                        report.SetParameterValue(item.paramName, item.paramValue);
    
                    if(_design)
                        report.Design();
                    else
                        report.Show();
                }
            }
    

    report. --> does not have any property to set default folder to save generated files [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> report.Show() --> does not have version with parameter to set path folder[/img]>
  • edited 11:55PM
    In this case you can use following code:
    Report report = new Report();
    report.Prepare();
    FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
    SaveFileDialog dialog = new SaveFileDialog();
    dialog.InitialDirectory = @"C:\Guest\Test\Documents\Reports"; // default folder for generating reports
    dialog.Filter = "PDF file (*.pdf)|*.pdf";
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        report.Export(export, dialog.FileName);
    }
    
  • edited May 2011
    Thank you OlegK!

    This is almost what I need [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I wounder, if there could be method like:[/img]report.InitialDirectory(...)...
    (you use: dialog.InitialDirectory(...)).

    So I think, if I would use default folder, I have to make something
    like enum, which will contain all possibility of generated type files (pdf, html and so on)
    and I will allow user to choose one of them... It is no problem at all [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Anyway -> thank you very much[/img]>, in that case I think I will use it in my application[img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> //by the way If there is any wish-list I would put my wish: method:[/img]report.InitialDirectory(string path).
  • edited 11:55PM
    I too was trying to set default folder so that report can be generated automatically. I was searching for the answer from long ago even I have googled it but didn???t come across satisfactory answer. Thanks olegk for sharing this information with us which is really helped us a lot. I don???t think as you said you have little knowledge in this but you seem to be perfect.Looking forward to see more such stuffs from you.Also I will try my best to contribute in this forum and share my knowledge with the other users.

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.