c# - Generate and Design Rdlc file programmatically -


i'm doing mvc reporting , i'm new @ it. i'm trying create report, , have done using rdlc. works well, can exported various format. problem, when using rdlc need design , bind first. how can create empty rdlc template, design , bind dataset programmatically.

my work far (using empty rdlc template - created file without table),

controller file,

public actionresult report(string id)     {         db.open();         localreport lr1 = new localreport();         string path1 = path.combine(server.mappath("~/report"), "testemptyreport.rdlc");         lr1.reportpath = path1;         datatable pc2a = new datatable();         pc2a = db.getdataset().tables[0];         pc2a.columns.add("product name");         pc2a.columns.add("price");         pc2a.columns.add("quantity");         reportdatasource rdc = new reportdatasource("dataset1", pc2a);         lr1.datasources.add(rdc);          string reporttype = id;         string mimetype;         string encoding;         string filenameextension;          string deviceinfo =              "<deviceinfo>" +             "<outputformat>" + id + "</outputformat>" +             "<pagewidth>8.5in</pagewidth>" +             "<pageheight>11in</pageheight>" +             "<margintop>0.5in</margintop>" +             "<marginleft>1in</marginleft>" +             "<marginright>1in</marginright>" +             "<marginbottom>0.5in</marginbottom>" +             "</deviceinfo>";          warning[] warnings;         string[] streams;         byte[] renderedbytes;          renderedbytes = lr1.render(             reporttype,             deviceinfo,             out mimetype,             out encoding,             out filenameextension,             out streams,             out warnings);          return file(renderedbytes, mimetype);      } 

model file,

public dataset getdataset()     {         string query = "select * tblproduct";         if (con.state.tostring() == "open")         {             sqldataadapter ad = new sqldataadapter(query, con);             dataset ds = new dataset("tblproduct");              ad.fill(ds);              return ds;         }         else         {             return null;         }     } 

view file,

<div style="padding: 10px; border: 1px solid black"> <div><a href="@url.action("report", new { id = "pdf" })">get pdf report</a></div> <div><a href="@url.action("report", new { id = "excel" })">get excel report</a></div> <div><a href="@url.action("report", new { id = "word" })">get word report</a></div> <div><a href="@url.action("report", new { id = "image" })">get image report</a></div> 

the data there, dont know how connect rdlc. means creating column based on data , fill data called sql server.

tqvm in advanced. explanation , example or other method helpful.

if understand question correctly wanted create report blank rdlc. have tell rdlc file data in design time. can customize report in design time adding columns or columns table or make join.

whereas dynamic rdlc generator through c# there generate report dynamically rdlc. since complete reportingengine has been custom made generic. copy paste might going generating report.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -