Home > DeveloperSection > Forums > how to calculate total invoice amount in footer rdlc report in mvc
Ankit Singh

Total Post:341

Posted on    February-16-2016 9:45 PM

 Reporting C#  Reporting  Mvc 

 1 Reply(s)
 1188  View(s)
Rate this:
I want to  calculate total invoice amount in report footer section how will do this please help me.

aditya kumar Patel

Total Post:254

Posted on    February-16-2016 10:02 PM

here we are going to demonstrate how to calculate amount in footer . Follow the below steps.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using System.Data;
using Microsoft.Reporting.WebForms;
using System.IO;
using ForumMVC;
using ForumMVC.Models;
using System.ComponentModel;
namespace ForumMVC.Controllers
public class HomeController : Controller
forumEntities1 db = new forumEntities1();
public ActionResult Index()

return View();

public ActionResult PrintPDF()
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Graph.rdlc");
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet1";
DataSet ds = new DataSet();
DataTable dt = new DataTable();

var Result = from c in db.CUSTOMER
join o in db.ORDER on c.CUST_ID equals o.CUST_ID
join p in db.PRODUCT on o.PRODUCT_ID equals p.PRODUCT_ID
select new
Id = c.CUST_ID,
Name = c.CUST_NAME,
Date = o.ORD_DATE,
Product = p.PRODUCT_NAME,
Price = p.PRICE
dt = ConvertToDataTable(Result.Where(m => m.Id < 5).ToList());
reportDataSource.Value = ds.Tables[0];

ReportParameter[] parameters = new ReportParameter[3];
parameters[0] = new ReportParameter("Name", "Anupam Sing");
parameters[1] = new ReportParameter("Number", "7798930674");
parameters[2] = new ReportParameter("Date", DateTime.Now.ToString());
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;

string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>1in</MarginLeft>" +
" <MarginRight>1in</MarginRight>" +
" <MarginBottom>0.5in</MarginBottom>" +
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localReport.Render(
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-length", renderedBytes.Length.ToString());
Response.AddHeader("content-disposition", "inline;filename=Data." + fileNameExtension);
return null;

public DataTable ConvertToDataTable<T>(IList<T> data)
PropertyDescriptorCollection properties =
DataTable table = new DataTable();
foreach (PropertyDescriptor prop in properties)
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
foreach (T item in data)
DataRow row = table.NewRow();
foreach (PropertyDescriptor prop in properties)
row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
return table;



Index View
<!DOCTYPE html>
<meta name="viewport" content="width=device-width" />
<script src="~/Scripts/jquery-1.9.1.min.js"></script>
$(document).on('click', '.PrintPDF', function (e) {
var win = window.open('../Home/PrintPDF/', '_blank');
if (win) {
} else {
alert('Please allow popups for this site');
<input id="btnreportmvc" type="button" value="Print Invoice"
class="btn btn-info PrintPDF" style="margin-right: 10px;" />

Report Design

in this design we are adding custom line and total invoice bill amount calculate in footer section.
an separated by all section line.
Result Report


Modified On Feb-16-2016 10:04:41 PM

Don't want to miss updates? Please click the below button!

Follow MindStick