Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Updated the Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Sep 25, 2017
1 parent 2f4f5fe commit 05d7c4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/EPPlus.Core.SampleWebApp/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public async Task<IActionResult> FileUpload(IFormFile file)

using (var package = new ExcelPackage(memoryStream))
{
return Content(readExcelPackageToString(package, worksheetName: "Employee"));
var worksheet = package.Workbook.Worksheets[1]; // Tip: To access the first worksheet, try index 1, not 0
return Content(readExcelPackageToString(package, worksheet));
}
}
}
Expand All @@ -95,13 +96,12 @@ private string readExcelPackage(FileInfo fileInfo, string worksheetName)
{
using (var package = new ExcelPackage(fileInfo))
{
return readExcelPackageToString(package, worksheetName);
return readExcelPackageToString(package, package.Workbook.Worksheets[worksheetName]);
}
}

private string readExcelPackageToString(ExcelPackage package, string worksheetName)
private string readExcelPackageToString(ExcelPackage package, ExcelWorksheet worksheet)
{
var worksheet = package.Workbook.Worksheets[worksheetName]; // Tip: To access the first worksheet, try index 1, not 0 -> package.Workbook.Worksheets[1]
int rowCount = worksheet.Dimension.Rows;
int ColCount = worksheet.Dimension.Columns;

Expand Down
18 changes: 9 additions & 9 deletions src/EPPlus.Core.SampleWebApp/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<fieldset>
<fieldset>
<legend>Basic usage</legend>
<ul>
<li>
<a asp-action="InMemoryReport" asp-controller="Home">Create an in-memory report</a>
</li>
<a asp-action="InMemoryReport" asp-controller="Home">Create an in-memory report</a>
</li>
<li>
<a asp-action="FileReport" asp-controller="Home">Create a file report</a>
</li>
<a asp-action="FileReport" asp-controller="Home">Create a file report</a>
</li>
<li>
<a asp-action="ReadFile" asp-controller="Home">Read report.xlsx file</a>
</li>
<a asp-action="ReadFile" asp-controller="Home">Read report.xlsx file</a>
</li>
</ul>
</fieldset>

<fieldset style="margin-top: 15px">
<legend>Upload the above report.xlsx file</legend>
<fieldset style="margin-top: 15px">
<legend>Upload an xlsx file</legend>
<form method="post"
asp-action="FileUpload"
asp-controller="Home"
Expand Down
Binary file not shown.

0 comments on commit 05d7c4f

Please sign in to comment.