Всякий раз, когда я пытаюсь загрузить файл Excel, он сохраняет его как версию Excel 1997-2003 годов, и я использовал все типы контента и не мог найти решение, так как он все еще сохраняет его как «xls», а не «xlsx».
У меня есть метод экспорта, который имеет следующий код.
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
//HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename = " + fileName);