public IActionResult GetXls(string unitId, string duration, DateTime?dateFrom, DateTime?dateTo) { try { byte[] xlsInBytes; int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); DateTime DateFrom = dateFrom == null ? new DateTime(1970, 1, 1) : Convert.ToDateTime(dateFrom); DateTime DateTo = dateTo == null ? DateTime.Now : Convert.ToDateTime(dateTo); var xls = _facade.GenerateExcelPRDuration(unitId, duration, dateFrom, dateTo, offset); string filename = String.Format("Laporan Durasi PR - PO Internal - {0}.xlsx", DateTime.UtcNow.ToString("ddMMyyyy")); xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }