I am developing a report in excel format from my .net web application. I am using Open XML SDK to create the excel spreadsheet. The code is working fine when I run it on Visual Studio. But when I publish the application and host it on the IIS server in my machine, it gives me an error. My code is shown below
public void getPivotTable(System.Data.DataTable dt)
{
string exportFile = Context.Server.MapPath("~/files_all/Export/generated.xlsx");
string templateFile = Context.Server.MapPath("~/files_all/Export/template.xlsx");
File.Copy(templateFile, exportFile, true);
using (SpreadsheetDocument spreadsheet = SpreadsheetDocument.Open(exportFile, true))
{
WorkbookPart workbook = spreadsheet.WorkbookPart;
WorksheetPart worksheet = workbook.WorksheetParts.Last();
SheetData data = worksheet.Worksheet.GetFirstChild<SheetData>();
}
Webpage error details
Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Please help me solve the issue.