EMI Calculator 2026 – Home, Car & Personal Loan | Download Amortisation Schedule Excel
{“@context”:”
https://schema.org” ;,”@type”:”WebApplication”,”name”:”EMI Calculator India”,”url”:”
https://Fundicast.in/emi-calculator/” ;,”description”:”Free online EMI calculator for Home Loan, Car Loan and Personal Loan in India. Calculate monthly EMI and download full amortisation schedule in Excel.”,”applicationCategory”:”FinanceApplication”,”operatingSystem”:”All”,”offers”:{“@type”:”Offer”,”price”:”0″,”priceCurrency”:”INR”},”inLanguage”:”en-IN”,”featureList”:[“Home Loan EMI Calculation”,”Car Loan EMI Calculation”,”Personal Loan EMI Calculation”,”Amortisation Schedule”,”Excel Download”]}
{“@context”:”
https://schema.org” ;,”@type”:”BreadcrumbList”,”itemListElement”:[{“@type”:”ListItem”,”position”:1,”name”:”Home”,”item”:”
https://Fundicast.in/” ;},{“@type”:”ListItem”,”position”:2,”name”:”Calculators”,”item”:”
https://Fundicast.in/calculators/” ;},{“@type”:”ListItem”,”position”:3,”name”:”EMI Calculator”,”item”:”
https://Fundicast.in/emi-calculator/” ;}]}
{“@context”:”
https://schema.org” ;,”@type”:”FAQPage”,”mainEntity”:[{“@type”:”Question”,”name”:”What is EMI?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”EMI stands for Equated Monthly Instalment. It is the fixed monthly amount paid to repay a loan. Each EMI has two parts: principal repayment and interest charged for the month.”}},{“@type”:”Question”,”name”:”What is the formula to calculate EMI?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”EMI = P × r × (1+r)ⁿ / [(1+r)ⁿ − 1]. Where P = Principal loan amount, r = Monthly interest rate (Annual rate ÷ 12 ÷ 100), n = Total number of monthly instalments.”}},{“@type”:”Question”,”name”:”How can I reduce my EMI?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”You can reduce your EMI by increasing the loan tenure, making a larger down payment, negotiating a lower interest rate with your bank, or making part-prepayments.”}},{“@type”:”Question”,”name”:”What is an amortisation schedule?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”An amortisation schedule is a month-by-month table showing every EMI payment split into principal and interest, plus the remaining loan balance after each payment.”}},{“@type”:”Question”,”name”:”Does EMI remain the same throughout the tenure?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”In fixed-rate loans, EMI stays constant. In floating-rate loans (most home loans in India), EMI may change when the bank revises its base rate.”}}]}
https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%;}
:root{
–ink:#1a1a2e;–ink2:#3d3d5c;–muted:#7a7a9a;
–bg:#f7f6f2;–surface:#fff;
–accent:#d4580a;–green:#1a6b4a;
–border:#e4e2dc;–rad:14px;
–shadow:0 2px 24px rgba(26,26,46,.08);
}
body{font-family:’DM Sans’,sans-serif;background:var(–bg);color:var(–ink);line-height:1.6;font-size:16px;}
img{max-width:100%;height:auto;}
a{color:var(–green);}
/* LAYOUT */
.wrap{max-width:960px;margin:0 auto;padding:1.5rem 1rem 5rem;}
/* BREADCRUMB */
.bc{font-size:12px;color:var(–muted);margin-bottom:1.25rem;display:flex;flex-wrap:wrap;gap:4px;align-items:center;}
.bc a{color:var(–muted);text-decoration:none;}.bc a:hover{color:var(–green);}
/* HERO */
.hero{text-align:center;margin-bottom:1.75rem;padding:0 .5rem;}
.badge{display:inline-block;background:#fff3ec;color:var(–accent);font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;padding:4px 12px;border-radius:20px;margin-bottom:.75rem;border:1px solid #ffd4b8;}
.hero h1{font-family:’DM Serif Display’,serif;font-size:clamp(1.55rem,5vw,2.6rem);line-height:1.15;margin-bottom:.5rem;}
.hero p{font-size:clamp(13px,3vw,15px);color:var(–muted);max-width:520px;margin:0 auto;}
/* CARD */
.card{background:var(–surface);border-radius:var(–rad);border:1px solid var(–border);box-shadow:var(–shadow);padding:clamp(.875rem,4vw,2rem);margin-bottom:1.5rem;}
/* INPUT GRID — 2col desktop, 1col mobile */
.igrid{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-bottom:1.25rem;}
@media(max-width:500px){.igrid{grid-template-columns:1fr;gap:.875rem;}}
.field>label{display:block;font-size:11px;font-weight:600;color:var(–muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:6px;}
.iw{position:relative;}
.iw .pfx{position:absolute;left:13px;top:50%;transform:translateY(-50%);font-size:15px;font-weight:600;color:var(–muted);pointer-events:none;z-index:1;}
.iw input,.iw select{
width:100%;height:48px;border:1.5px solid var(–border);border-radius:10px;
font-family:’DM Sans’,sans-serif;font-size:15px;font-weight:500;color:var(–ink);
background:var(–bg);transition:border-color .2s,background .2s;outline:none;
-webkit-appearance:none;appearance:none;
}
/* iOS zoom fix — needs 16px on mobile */
@media(max-width:767px){.iw input,.iw select{font-size:16px;}}
.iw input{padding:0 12px 0 34px;}
.iw select{padding:0 36px 0 12px;background-image:url(“data:image/svg+xml,%3Csvg xmlns=’
http://www.w3.org/2000/svg’ ; width=’12’ height=’8’%3E%3Cpath d=’M1 1l5 5 5-5′ stroke=’%237a7a9a’ stroke-width=’1.5′ fill=’none’ stroke-linecap=’round’/%3E%3C/svg%3E”);background-repeat:no-repeat;background-position:right 13px center;}
.iw input:focus,.iw select:focus{border-color:var(–accent);background:#fff;}
.iw.np input{padding-left:12px;}
/* RANGE */
.rw{margin-top:7px;}
input[type=range]{width:100%;-webkit-appearance:none;appearance:none;height:4px;background:var(–border);border-radius:4px;outline:none;cursor:pointer;}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;background:var(–accent);border-radius:50%;cursor:pointer;border:3px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.2);}
input[type=range]::-moz-range-thumb{width:20px;height:20px;background:var(–accent);border-radius:50%;cursor:pointer;border:3px solid #fff;}
.rl{display:flex;justify-content:space-between;font-size:11px;color:var(–muted);margin-top:3px;}
/* BUTTON */
.cbtn{width:100%;height:52px;background:var(–ink);color:#fff;border:none;border-radius:10px;font-family:’DM Sans’,sans-serif;font-size:15px;font-weight:600;cursor:pointer;letter-spacing:.02em;transition:background .2s,transform .1s;touch-action:manipulation;}
.cbtn:hover{background:var(–accent);}
.cbtn:active{transform:scale(.99);}
/* RESULTS */
.res{display:none;margin-top:1.5rem;}.res.show{display:block;}
/* RESULT BOXES — 2col mobile, 4col desktop */
.rg{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:1.5rem;}
@media(min-width:580px){.rg{grid-template-columns:repeat(4,1fr);}}
.rb{background:var(–bg);border-radius:10px;padding:.875rem 1rem;border:1px solid var(–border);}
.rb.hi{background:var(–ink);border-color:var(–ink);}
.rb .rl2{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(–muted);margin-bottom:5px;}
.rb.hi .rl2{color:rgba(255,255,255,.5);}
.rb .rv{font-family:’DM Serif Display’,serif;font-size:clamp(1.1rem,3.5vw,1.5rem);color:var(–ink);line-height:1.1;word-break:break-all;}
.rb.hi .rv{color:#fff;}
.rb .rs{font-size:11px;color:var(–muted);margin-top:3px;}
.rb.hi .rs{color:rgba(255,255,255,.4);}
/* DONUT */
.ds{display:flex;align-items:center;gap:1.5rem;flex-wrap:wrap;margin-bottom:1.5rem;}
@media(max-width:380px){.ds{justify-content:center;}}
.dw{flex:0 0 130px;}
svg.donut{display:block;}
.dl{flex:1;min-width:150px;}
.li{display:flex;align-items:center;gap:10px;margin-bottom:10px;}
.ld{width:11px;height:11px;border-radius:50%;flex-shrink:0;}
.linfo{font-size:13px;}.linfo strong{display:block;font-weight:600;color:var(–ink);}.linfo span{color:var(–muted);font-size:12px;}
/* DIVIDER */
hr.div{border:none;border-top:1px solid var(–border);margin:1.5rem 0;}
/* SCHEDULE */
.sh{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:1rem;}
.sh h2{font-family:’DM Serif Display’,serif;font-size:clamp(1.05rem,4vw,1.3rem);}
.dlbtn{display:inline-flex;align-items:center;gap:7px;padding:9px 16px;background:var(–green);color:#fff;border:none;border-radius:8px;font-family:’DM Sans’,sans-serif;font-size:13px;font-weight:600;cursor:pointer;transition:background .2s;touch-action:manipulation;white-space:nowrap;}
.dlbtn:hover{background:#145c3e;}
.dlbtn svg{width:14px;height:14px;fill:none;stroke:#fff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0;}
/* TOGGLE */
.tog{display:flex;align-items:center;gap:10px;margin-bottom:1rem;flex-wrap:wrap;}
.tl{font-size:11px;font-weight:600;color:var(–muted);text-transform:uppercase;letter-spacing:.06em;}
.tbs{display:flex;gap:3px;background:var(–bg);border:1px solid var(–border);border-radius:8px;padding:3px;}
.tb{padding:5px 14px;font-size:12px;font-weight:600;border:none;border-radius:6px;cursor:pointer;font-family:’DM Sans’,sans-serif;background:transparent;color:var(–muted);transition:all .15s;touch-action:manipulation;}
.tb.on{background:var(–ink);color:#fff;}
/* TABLE */
.tw{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:10px;border:1px solid var(–border);}
table{width:100%;border-collapse:collapse;font-size:13px;min-width:400px;}
thead th{background:var(–ink);color:#fff;padding:10px 12px;text-align:right;font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.06em;white-space:nowrap;}
thead th:first-child{text-align:left;}
tbody tr{border-bottom:1px solid var(–border);transition:background .1s;}
tbody tr:last-child{border-bottom:none;}
tbody tr:hover{background:#faf9f6;}
tbody td{padding:9px 12px;text-align:right;color:var(–ink2);}
tbody td:first-child{text-align:left;font-weight:500;color:var(–ink);}
.tp{color:var(–green);font-weight:500;}
.ti{color:var(–accent);font-weight:500;}
.tb2{color:var(–muted);}
tfoot td{padding:10px 12px;font-weight:700;background:var(–bg);text-align:right;font-size:12px;color:var(–ink);border-top:2px solid var(–border);}
tfoot td:first-child{text-align:left;}
/* INFO */
.info{background:#f0faf5;border:1px solid #b8e6d0;border-radius:10px;padding:1rem 1.25rem;margin-top:1.5rem;font-size:13px;color:var(–ink2);line-height:1.75;}
.info strong{color:var(–ink);}
/* SEO CONTENT */
.seo{margin-top:2.5rem;}
.seo h2{font-family:’DM Serif Display’,serif;font-size:clamp(1.15rem,4vw,1.55rem);margin-bottom:.75rem;}
.seo h3{font-family:’DM Serif Display’,serif;font-size:clamp(1rem,3vw,1.2rem);margin:1.5rem 0 .5rem;}
.seo p{font-size:14px;color:var(–ink2);line-height:1.8;margin-bottom:.75rem;}
.seo ul{font-size:14px;color:var(–ink2);line-height:1.8;margin-bottom:.75rem;padding-left:1.2rem;}
.seo ul li{margin-bottom:.2rem;}
.rate-table{width:100%;border-collapse:collapse;font-size:13px;margin:.75rem 0 1rem;border-radius:10px;overflow:hidden;border:1px solid var(–border);}
.rate-table th{background:var(–ink);color:#fff;padding:9px 14px;text-align:left;font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.06em;}
.rate-table td{padding:9px 14px;border-bottom:1px solid var(–border);color:var(–ink2);}
.rate-table tr:last-child td{border-bottom:none;}
.rate-table td:last-child{text-align:right;font-weight:500;color:var(–ink);}
/* FAQ */
.faq{margin-top:2rem;}
.faq h2{font-family:’DM Serif Display’,serif;font-size:clamp(1.15rem,4vw,1.5rem);margin-bottom:1rem;}
.fi{border:1px solid var(–border);border-radius:10px;margin-bottom:10px;overflow:hidden;}
.fq{width:100%;text-align:left;background:var(–surface);border:none;padding:1rem 1.25rem;font-family:’DM Sans’,sans-serif;font-size:14px;font-weight:600;color:var(–ink);cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:12px;line-height:1.4;touch-action:manipulation;}
.fq:hover{background:#faf9f6;}
.fa-arrow{width:18px;height:18px;flex-shrink:0;transition:transform .25s;}
.fa{display:none;padding:.75rem 1.25rem 1rem;font-size:13px;color:var(–ink2);line-height:1.75;border-top:1px solid var(–border);background:#fafaf8;}
.fi.op .fa{display:block;}.fi.op .fa-arrow{transform:rotate(180deg);}
/* RELATED */
.rel{margin-top:2rem;}
.rel h2{font-family:’DM Serif Display’,serif;font-size:clamp(1.1rem,4vw,1.4rem);margin-bottom:1rem;}
.tg2{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:10px;}
.tl2{display:block;background:var(–surface);border:1px solid var(–border);border-radius:10px;padding:.875rem 1rem;text-decoration:none;color:var(–ink);font-size:13px;font-weight:500;transition:border-color .2s,background .2s;text-align:center;}
.tl2:hover{border-color:var(–green);background:#f0faf5;color:var(–green);}
.tl2 small{display:block;font-size:11px;color:var(–muted);font-weight:400;margin-top:3px;}
/* STICKY EMI BAR (mobile only) */
.sticky{display:none;position:fixed;bottom:0;left:0;right:0;background:var(–ink);color:#fff;padding:.75rem 1.25rem;flex-direction:row;align-items:center;justify-content:space-between;z-index:200;box-shadow:0 -2px 12px rgba(0,0,0,.15);}
.sticky.show{display:flex;}
.sticky .sl{font-size:11px;color:rgba(255,255,255,.5);text-transform:uppercase;letter-spacing:.06em;}
.sticky .sv{font-family:’DM Serif Display’,serif;font-size:1.25rem;}
.sticky .sc{background:rgba(255,255,255,.15);border:none;color:#fff;width:28px;height:28px;border-radius:50%;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;flex-shrink:0;touch-action:manipulation;}
/* A11Y */
.sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
Home ›
Calculators ›
EMI Calculator
Free Indian Finance Tool
EMI Calculator
Calculate your monthly EMI for Home Loan, Car Loan & Personal Loan. Download full amortisation schedule in Excel — free, instant, no sign-up.
Loan Type
Home Loan
Car Loan
Personal Loan
Education Loan
Other Loan
Calculate EMI
Total Interest
₹0
0% of principal
Total Payment
₹0
over 0 months
Chart showing principal versus interest split
0%
interest
Amortisation Schedule
Download Excel
#
Date
EMI (₹)
Principal (₹)
Interest (₹)
Balance (₹)
EMI Formula: EMI = P × r × (1+r)ⁿ / [(1+r)ⁿ − 1] |
P = Principal | r = Monthly rate (Annual ÷ 1200) | n = Months
What is an EMI Calculator?
An EMI (Equated Monthly Instalment) Calculator is an online tool that instantly tells you the fixed monthly amount you need to pay to repay your loan. Whether you are planning a home loan , car loan , or personal loan , this calculator gives you results in seconds — no manual maths needed.
EMI Formula
This calculator uses the standard reducing-balance formula used by all Indian banks — SBI, HDFC, ICICI, Axis Bank, and others:
EMI = P × r × (1+r)ⁿ ÷ [(1+r)ⁿ − 1]
P — Principal loan amount (₹)
r — Monthly interest rate = Annual rate ÷ 12 ÷ 100
n — Total months = Tenure in years × 12
How to use this EMI Calculator
Enter your loan amount or drag the slider
Enter the annual interest rate your bank offers
Choose your loan tenure in years
Select loan type and start month
See your EMI instantly — the schedule updates in real time
Click Download Excel for the full amortisation schedule
Current Loan Interest Rates in India (2026)
Loan Type Interest Rate (p.a.)
Home Loan (SBI, HDFC, LIC HFL) 8.40% – 9.50%
Car Loan 8.75% – 12.00%
Personal Loan 10.50% – 24.00%
Education Loan 8.85% – 14.00%
Two-Wheeler Loan 9.00% – 18.00%
Frequently Asked Questions
What is EMI?
EMI stands for Equated Monthly Instalment . It is the fixed monthly amount you pay to your bank to repay your loan. Each EMI has two parts: the principal component (reduces your loan balance) and the interest component . In early months, most of the EMI goes toward interest. Over time, more of it reduces the principal.
What is an amortisation schedule?
An amortisation schedule is a complete month-by-month breakdown of every EMI payment over your loan tenure. For each month it shows: the total EMI paid, how much went to principal, how much was interest, and the outstanding loan balance. It is very useful for tax planning (Section 24b deduction on home loan interest), prepayment decisions, and tracking progress.
How can I reduce my loan EMI?
Four effective ways to reduce your EMI: (1) Increase the tenure — a 20-year loan has lower EMI than a 10-year loan, though total interest is higher. (2) Make a larger down payment to reduce the principal. (3) Negotiate a lower rate — a CIBIL score above 750 gives you bargaining power with banks. (4) Make partial prepayments to bring down the outstanding principal and reduce future EMIs.
Does EMI change during the loan tenure?
For fixed-rate loans , the EMI stays constant throughout the tenure. For floating-rate loans (which most home loans in India are — linked to RLLR or MCLR), the EMI may change when the bank revises the base lending rate. When rates rise, either your EMI increases or your tenure gets extended. When rates fall, you get the benefit.
Is this EMI calculator accurate?
Yes — this calculator uses the exact same formula used by all Indian banks. Results match the official EMI to the nearest rupee. Minor differences of ₹1–₹2 may occur due to the exact disbursement date, processing fees, or GST on interest. Always confirm the final EMI with your lender’s official sanction letter or loan statement.
Other Finance Calculators
let data=[], view=’m’;
const mn=[‘Jan’,’Feb’,’Mar’,’Apr’,’May’,’Jun’,’Jul’,’Aug’,’Sep’,’Oct’,’Nov’,’Dec’];
const now=new Date();
document.getElementById(‘startDate’).value=now.toISOString().slice(0,7);
const f=n=>’₹’+Math.round(n).toLocaleString(‘en-IN’);
const fn=n=>Math.round(n).toLocaleString(‘en-IN’);
function syncR(id){const r=document.getElementById(id+’R’);if(r)r.value=document.getElementById(id).value;}
function syncI(id){document.getElementById(id).value=document.getElementById(id+’R’).value;}
let act;
function ac(){clearTimeout(act);act=setTimeout(calc,280);}
function calc(){
const P=parseFloat(document.getElementById(‘principal’).value);
const ar=parseFloat(document.getElementById(‘rate’).value);
const ty=parseInt(document.getElementById(‘tenure’).value);
const sv=document.getElementById(‘startDate’).value;
if(!P||!ar||!ty||P<1000)return;
const r=ar/12/100, n=ty*12;
const emi=P*r*Math.pow(1+r,n)/(Math.pow(1+r,n)-1);
const tot=emi*n, tint=tot-P;
document.getElementById('emiVal').textContent=f(emi);
document.getElementById('pVal').textContent=f(P);
document.getElementById('iVal').textContent=f(tint);
document.getElementById('tVal').textContent=f(tot);
document.getElementById('iPct').textContent=(tint/P*100).toFixed(1)+'% of principal';
document.getElementById('tDisp').textContent='over '+n+' months';
const circ=2*Math.PI*46;
const pArc=circ*(P/tot), iArc=circ*(tint/tot);
document.getElementById('dPct').textContent=(tint/tot*100).toFixed(1)+'%';
document.getElementById('dP').setAttribute('stroke-dasharray',pArc+' '+circ);
document.getElementById('dI').setAttribute('stroke-dasharray',iArc+' '+circ);
document.getElementById('dI').setAttribute('stroke-dashoffset',-pArc);
document.getElementById('lgP').textContent=f(P);
document.getElementById('lgI').textContent=f(tint);
document.getElementById('lgT').textContent=f(tot);
let bal=P; data=[];
let [sy,sm]=sv?sv.split('-').map(Number):[now.getFullYear(),now.getMonth()+1];
for(let i=1;i<=n;i++){
const int=bal*r, pri=Math.min(emi-int,bal);
bal=Math.max(0,bal-pri);
const mi=(sm-1+i-1)%12, yr=sy+Math.floor((sm-1+i-1)/12);
data.push({no:i,date:mn[mi]+' '+yr,emi,principal:pri,interest:int,balance:bal,year:yr});
}
renderT();
document.getElementById('results').classList.add('show');
document.getElementById('stickyEmi').textContent=f(emi);
if(window.innerWidth{tp+=r.principal;ti+=r.interest;te+=r.emi;
rows+=`
${r.no} ${r.date} ${fn(r.emi)} ${fn(r.principal)} ${fn(r.interest)} ${fn(r.balance)} `;
});
sb.innerHTML=rows;
sf.innerHTML=`
Total ${fn(te)} ${fn(tp)} ${fn(ti)} — `;
} else {
const yrs={};
data.forEach(r=>{if(!yrs[r.year])yrs[r.year]={e:0,p:0,i:0,b:0};yrs[r.year].e+=r.emi;yrs[r.year].p+=r.principal;yrs[r.year].i+=r.interest;yrs[r.year].b=r.balance;});
let tp=0,ti=0,te=0,idx=1;
Object.entries(yrs).forEach(([yr,d])=>{tp+=d.p;ti+=d.i;te+=d.e;
rows+=`
${idx++} ${yr} ${fn(d.e)} ${fn(d.p)} ${fn(d.i)} ${fn(d.b)} `;
});
sb.innerHTML=rows;
sf.innerHTML=`
Total ${fn(te)} ${fn(tp)} ${fn(ti)} — `;
}
}
function sw(v){
view=v;
const bm=document.getElementById(‘bM’),by=document.getElementById(‘bY’);
bm.classList.toggle(‘on’,v===’m’); by.classList.toggle(‘on’,v===’y’);
bm.setAttribute(‘aria-checked’,v===’m’); by.setAttribute(‘aria-checked’,v===’y’);
renderT();
}
function tf(btn){
const fi=btn.closest(‘.fi’), was=fi.classList.contains(‘op’);
document.querySelectorAll(‘.fi.op’).forEach(el=>{el.classList.remove(‘op’);el.querySelector(‘.fq’).setAttribute(‘aria-expanded’,’false’);});
if(!was){fi.classList.add(‘op’);btn.setAttribute(‘aria-expanded’,’true’);}
}
function dlXL(){
if(!data.length)return;
const P=parseFloat(document.getElementById(‘principal’).value);
const rate=parseFloat(document.getElementById(‘rate’).value);
const tenure=parseInt(document.getElementById(‘tenure’).value);
const lt=document.getElementById(‘loanType’);
const loanType=lt.options[lt.selectedIndex].text;
const emi=data[0].emi;
const tint=data.reduce((s,r)=>s+r.interest,0);
const tot=data.reduce((s,r)=>s+r.emi,0);
const wb=XLSX.utils.book_new();
// Summary sheet
const ws1=XLSX.utils.aoa_to_sheet([
[‘EMI CALCULATOR – LOAN SUMMARY’,”,”],
[‘Indian Finance Tools’,”,”],
[”,”,”],
[‘LOAN DETAILS’,”,”],
[‘Loan Type’,loanType,”],
[‘Principal Amount (₹)’,Math.round(P),”],
[‘Annual Interest Rate (%)’,rate,”],
[‘Loan Tenure (Years)’,tenure,”],
[‘Loan Tenure (Months)’,tenure*12,”],
[”,”,”],
[‘RESULTS’,”,”],
[‘Monthly EMI (₹)’,Math.round(emi),”],
[‘Total Principal (₹)’,Math.round(P),”],
[‘Total Interest (₹)’,Math.round(tint),”],
[‘Total Amount Payable (₹)’,Math.round(tot),”],
[‘Interest as % of Principal’,((tint/P)*100).toFixed(2)+’%’,”],
]);
ws1[‘!cols’]=[{wch:32},{wch:22},{wch:10}];
XLSX.utils.book_append_sheet(wb,ws1,’Summary’);
// Monthly sheet
const mH=[‘Month No.’,’Month-Year’,’EMI (₹)’,’Principal (₹)’,’Interest (₹)’,’Closing Balance (₹)’];
const mR=data.map(r=>[r.no,r.date,Math.round(r.emi),Math.round(r.principal),Math.round(r.interest),Math.round(r.balance)]);
mR.push([‘TOTAL’,”,Math.round(data.reduce((s,r)=>s+r.emi,0)),Math.round(data.reduce((s,r)=>s+r.principal,0)),Math.round(data.reduce((s,r)=>s+r.interest,0)),’—’]);
const ws2=XLSX.utils.aoa_to_sheet([mH,…mR]);
ws2[‘!cols’]=[{wch:12},{wch:14},{wch:14},{wch:16},{wch:14},{wch:20}];
XLSX.utils.book_append_sheet(wb,ws2,’Monthly Schedule’);
// Yearly sheet
const yrs={};
data.forEach(r=>{if(!yrs[r.year])yrs[r.year]={e:0,p:0,i:0,b:0};yrs[r.year].e+=r.emi;yrs[r.year].p+=r.principal;yrs[r.year].i+=r.interest;yrs[r.year].b=r.balance;});
const yH=[‘Year No.’,’Year’,’Total EMI (₹)’,’Principal Paid (₹)’,’Interest Paid (₹)’,’Closing Balance (₹)’];
const yR=Object.entries(yrs).map(([yr,d],i)=>[i+1,parseInt(yr),Math.round(d.e),Math.round(d.p),Math.round(d.i),Math.round(d.b)]);
yR.push([‘TOTAL’,”,Math.round(Object.values(yrs).reduce((s,d)=>s+d.e,0)),Math.round(Object.values(yrs).reduce((s,d)=>s+d.p,0)),Math.round(Object.values(yrs).reduce((s,d)=>s+d.i,0)),’—’]);
const ws3=XLSX.utils.aoa_to_sheet([yH,…yR]);
ws3[‘!cols’]=[{wch:10},{wch:8},{wch:16},{wch:18},{wch:16},{wch:20}];
XLSX.utils.book_append_sheet(wb,ws3,’Yearly Schedule’);
XLSX.writeFile(wb,`EMI_${loanType.replace(/\s+/g,’_’)}_${Math.round(P/100000)}L_${rate}pct_${tenure}yr.xlsx`);
}
calc();