Page 1 of 1

Loading DataTable to Excel Format

Posted: Sun Feb 05, 2017 6:01 am
by BigStar
Hello,

I'm using ASP.NET web form and VB Language to create report generating page and getting data from created stored procedure that was wrote in MSSQL with 3 input variables. That data were returned as "datatable" datatype in program. I try to bind datatable to report with these codes:

' ------------------------------------------ Data that reurned in datatable format from --------------------------------------------------
Dim ReportInfo As DataTable = ContractReport.GetDetialReport(ContractId, Session("sdate"), Session("edate"))
' -------------------------------------------------------------------------------------------------------------------------------------------------
Dim Report As StiReport = New StiReport()
Report.Load(Server.MapPath("~/reports/Reports.mrt"))
Report.RegData("ReportInfo", ReportInfo)
Report.Render(False)
Dim mySettings = New StiExcelExportSettings()
mySettings.ExportDataOnly = True
mySettings.UseOnePageHeaderAndFooter = True
StiReportResponse.ResponseAsXls(Report, mySettings, True)

I create report template with name of "Reports.mrt" that have no connected to database.With all of attemptions, the generated report was empty. Could you please show me how to do it with sample.

Thanks in advance.

Re: Loading DataTable to Excel Format

Posted: Mon Feb 06, 2017 1:45 pm
by HighAley
Hello.

Do you have such Data Source in your report?
What data connection do you use in the report?
Could you send us your report template?

Thank you.

Re: Loading DataTable to Excel Format

Posted: Tue Feb 07, 2017 5:33 am
by BigStar
Yes, I retrieve that Data Source from Data Access defined layer and pass information of database to method of logic layer. I also connect designed report in stimulsoft to database and select specified stored procedure.In below picture I design that report and save in one of folder in my project.

Thank you very much.

Re: Loading DataTable to Excel Format

Posted: Wed Feb 08, 2017 8:44 am
by BigStar
Hello,

I Find solution. I Add below code:

Report.Load(Server.MapPath("~/reports/Reports.mrt"))
Report.Compile()
Report("@FDate") = Convert.ToString(Session("sdate"))
Report("@TDate") = Convert.ToString(Session("edate"))
Report("@ContractID") = Convert.ToInt32(ContractId)
Report.Render()

and problem solved.

Thanks again.

Re: Loading DataTable to Excel Format

Posted: Wed Feb 08, 2017 10:04 pm
by Alex K.
Hello,

Ok.
Please let us know if you need any additional help.

Thank you.