I'm developing an MVC application with razor view engine and I need to export the view result to Excel. The view result contains a list of div
and ul
tags. My view will be look like this.
@foreach (var alphabet in Model)
{
<div class="ioslist-group-container-rule" data-value="@alphabet.Alphabet">
<div class="ioslist-group-header-rule alphabet">@alphabet.Alphabet</div>
<ul style="margin-left: -40px; margin-top: 0px;">
@foreach (var rule in alphabet.Rules)
{
<li class="rule-item" id="@rule.RuleID">@rule.Name</li>
}
</ul>
</div>
}
I referred this link Export to Excel
It writes the HTML string in the Excel file instead HTML styled result. How can I do this without using ExcelWorksheet class or something else?