SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Need a guide to create report

Last post 06-23-2012 7:08 PM by Peter Forstmeier. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 06-14-2012 6:29 PM

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Need a guide to create report

    Hi everyone,

    I'm new to programming and c#, too. I'd like to create a report. I was searching through this forum, read many examples but was unsuccessful to figure out how this is work. I'd like to use the push data model, becouse I prefer to use FireBird database in my applications. 

    From the datatable I can create the .xsd file, and the report shows the fields, but from this point I couldn't find any example how to load data into the report. Beside this question, I'd like to know how to change values in report in runtime. For example, I have a basetextitem on my report, and I'd like to set its value.

    Please, help me with a detailed, step-by-step guide, becouse I'm looking for the solution since two weeks without any success.

    Kind regards,

    Kyjan

    Filed under: , , ,
  • 06-14-2012 8:06 PM In reply to

    Re: Need a guide to create report

     Hi,

    in yourpathToSharpdeevelop\samples\SharpDevelopReports you will find a sample project.

    What you are looking for is the Report Customized-EventLog

    This report uses the PushData Model.

    The EventHandler used to change Items is commeted.

    Please let me know if this was helpfull

    Peter

     

  • 06-14-2012 10:18 PM In reply to

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Re: Need a guide to create report

    Hello Peter, 

    I've checked the file you mentioned before, but I'm still unable how to use this kind of report - or any kind of sharpreport. I've seen that you were talking about a doc file which was in older releases in sharpreport. Is this file still exists? Can I get it?

    Or can someone write my a step-by-step guide how to do this? 

    TIA

    Kyjan

  • 06-15-2012 8:05 PM In reply to

    Re: Need a guide to create report

     Hi,

    you can find the Wiki here:

    http://sharpdevelopreports.net/default.aspx?AspxAutoDetectCookieSupport=1

    i have not the time to write a step - step documentation for #Report but if  you have a closer look to the sources i'm shure you will find out how you can run a report. You can step line by line with the Debugger as well.

    Peter

  • 06-16-2012 7:16 PM In reply to

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Re: Need a guide to create report

    Thank you, Peter. I've checked the wiki, and will read the source code. One more question: if I create a guide, can I send it to you? 

    Regards,

    Kyjan

  • 06-17-2012 5:47 PM In reply to

    Re: Need a guide to create report

     Hi,

    shure

    Help is  allways needed

    Peter

  • 06-21-2012 4:44 PM In reply to

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Re: Need a guide to create report

    Hi Peter, as I promised before, here is the guide created by me. If something is wrong, please, feel free to correct.

     How to create a report with SharpReport (Push modell)

     

    First of all, with this method you can create a report from any database, becouse the report accepts a DataTable as a parameter.

     

    To create a report you need a datatable. From this datatable, you have to create an .xsd file. You can create the .xsd file as follows (I found this code on forum, from Peter):

     

    You need to create a DataTable before this code, and fill the table with content.

     

    DataTable table = new DataTable();

    System.IO.FileStream filestream = new System.IO.FileStream(''filename.xsd'', System.IO.FileMode.Create);

    XmlTextWriter xmlwriter = new XmlTextWriter(filestream, System.Text.Encoding.UTF8);

    xmlwriter.WriteStartDocument(true);

    table.WriteXml(xmlwriter, XmlWriteMode.WriteSchema);

    xmlwriter.Close();

     

    The lines above will create an .xsd file, which will contain your the datas of your datatable.

     

    On the top of your file, you want to add two using directive:

     

    using ICSharpCode.Reports.Core;

    using ICSharpCode.Reports.Core.Exporter;

     

    The next step is to create the report.

     

    In SharpDevelop, click Project → Add → New Item, and select SharpDevelop Reports from Misc category.

    Give a report a name, and click create. A window will open, where you can set up some options. First, we should give a report a name, set the file name, The next step is to choose the report model. In this case, we may choose the „Push data model”, select the page layout, and then click Next.

    On the next page, you should browse the .xsd file, created the steps before. If everything goes right, you should see the content of your xsd file, and are can choose wich columns should be in your report. After selection, click Finish.

     

    Now, our report is ready, filled with data. You can design your report graphically, and only the last step left. Show your report from program.

     

    The code which shows your report as follows:

     

    ReportEngine engine = new ReportEngine();

    ReportModel rm = ReportEngine.LoadReportModel(''yourreport.srd'');

    ReportParameters rp = new ReportParameters();

    engine.PreviewPushDataReport(''yourreport.srd'', table, rp);

     

    And thats all, folks! I hope I was able to help to someone.

     

     

    Filed under: ,
  • 06-21-2012 8:05 PM In reply to

    Re: Need a guide to create report

     Hi,

    great.

    Thanks

    Peter

  • 06-21-2012 10:26 PM In reply to

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Re: Need a guide to create report

    Thanks, Peter!

    One more question. The following code compiles without problem, but I'm unable to change the BaseTextItem1 Text property in my program.Can you tell me please, where is the error?

     ReportEngine re = new ReportEngine();
                ReportDocument document = new ReportDocument();
                ReportParameters rp = new ReportParameters();
                ReportModel rm = ReportEngine.LoadReportModel(path);

     BaseTextItem item = new BaseTextItem();
                    item=rm.DetailSection.Items[0as BaseTextItem;
                    if (item != null)
                    {
                         
                        BaseTextItem item1 = (BaseTextItem)rm.DetailSection.FindItem("BaseTextItem1");
                        if (item1 != null)
                        {
                             
                            item1.Text="New text";                        
                        }
                    }
                    
                    re.PreviewStandardReport(path, rp);

     

    Furthermore, I'm unable to change for example the color of the text. It is a form sheet report, but it looks like to me that I can change the values in design time, but i'm not allowed to change in run-time. Am I correct?

    If this is right, which model should I use to be able to change the properties in run-time?

    Thank you for your answer.

    Regards

    Kyjan 

    Filed under:
  • 06-22-2012 8:25 PM In reply to

    Re: Need a guide to create report

     Hi,

    as i said before, have a look to the samples.:

    private void RunContributorsWithParameters(string fileName)

    ..........

        creator.SectionRendering += PushPrinting;

    -------

     

        private void PushPrinting (object sender, SectionRenderEventArgs e )
            {

    here you can see how to alter controls during runtime

    }

    Peter

  • 06-23-2012 3:56 PM In reply to

    • Kyjan
    • Top 500 Contributor
    • Joined on 06-14-2012
    • Posts 13

    Re: Need a guide to create report

    Thanks, works like a charm

  • 06-23-2012 7:08 PM In reply to

    Re: Need a guide to create report

     You are welcome

    Peter

Page 1 of 1 (12 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.