У меня есть отчет, и его строка таблицы содержит более 2000. Когда количество строк равно 1050, файл Excel загружен правильно. В противном случае произошла ошибка сети. Данные извлекаются из контроллера. И используется просмотр таблицы. Javascript Функция используется для экспорта. к Excel. Если количество строк в таблице достигло 1050, загружено в Excel. В противном случае возникла проблема с сетью.
<script>
$(document).on('click', '#Report', function () {
exportThisWithParameter("example2_wrapper", "Media Report")
});
var exportThisWithParameter = (function () {
debugger
var uri = 'data:application/vnd.ms-excel;base64,',
template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head> <!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets> <x:ExcelWorksheet><x:Name>{worksheet}</x:Name> <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions> </x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook> </xml><![endif]--></head><body> <table>{table}</table></body></html>',
base64 = function (s) {
return window.btoa(unescape(encodeURIComponent(s)))
},
format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })
}
return function (tableID, excelName) {
var control = $("#Report");
var par = $(control).parent();
if ($(control).hasClass('downloadLink')) {
$(par).html('<a class="btn btn-info " id="Report" data-id="' + excelName + '" value="Generate Report">Generate Report</a>')
}
else {
tableID = document.getElementById(tableID);
alert(excelName); alert(tableID.innerHTML);
var ctx = { worksheet: excelName || 'Worksheet', table: tableID.innerHTML }
$(par).html('<a href="' + uri + base64(format(template, ctx)) + '" data-id="' + excelName + '" class="btn btn-success downloadLink" id="Report" download="' + excelName + '">File generated. Click here to download <span class="fa fa-download"></span></a>');
}
}
})
</script>
<div class="Container">
<div class="row">
<form id="frmMediaEntryCreate" method="post">
<div class="row">
<div class="col-md-12">
<div class="pull-right text-muted " style="margin-right: 10px;">
<button class="btn btn-info " id="Print" value="Print">Print <span><i class="fa fa-print"></i></span></button>
</div>
<div class="pull-right text-muted " style="margin-right: 10px;">
<button class="btn btn-info " id="Report" value="Generate Report">Generate Report</button>
</div>
</div>
</div>
<div class="box-body">
<div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
@Html.Action("ReportHeader", "Report")
<h3 class="col-md-12" style="text-align: center"><u>Media Report</u></h3>
<table class="table table-bordered table-hover table-condensed" id="tblMediaDetails">
<thead>
<tr>
<th style="text-align:center;">Sl.No</th>
<th>Title</th>
<th>Author
</th>
<th>Type
</th>
<th>Category
</th>
<th>Language
</th>
<th>Total Stock
</th>
<th>Present Stock
</th>
<th>Present Issue
</th>
</tr>
</thead>
<tbody>
@{
int i = 1;
foreach (var item in Model)
{
<tr>
<td style="text-align:center;">@i</td>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.LibraryAuthor.FirstName)
@Html.DisplayFor(modelItem => item.LibraryAuthor.MiddleName)
@Html.DisplayFor(modelItem => item.LibraryAuthor.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LibraryMediaType.MediaName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LibraryCategory.CategoryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LibraryLanguage.LanguageName)
</td>
@{
int copycount=0;
int issuecount = 0;
foreach (var cp in item.LibraryMediaEntryCopyDetails)
{
copycount++;
if (cp.IsIssued)
{
issuecount++;
}
}
}
@if(copycount>0)
{
<td>@copycount </td>
}
else
{
<td>-</td>
}
@if ((copycount - issuecount) > 0)
{
<td>@(copycount-issuecount)</td>
}
else
{
<td>-</td>
}
@if (issuecount > 0)
{
<td>@issuecount </td>
}
else
{
<td>-</td>
}
</tr>
i++;
}
}
</tbody>
</table>
</div>
</div>
<div class="Nodata alert alert-warning alert-dismissible col-md-8" style="display: none">
<h4><i class="icon fa fa-warning"></i> Alert!</h4>
<p>No Records found</p>
</div>
<div id="reportId" class="col-md-12 panel panel-body-table table-responsive ">
</div>
</form>
</div>
</div>