public async Task <ResponseObject <string> > ExportOpeningTemplate() { try { CurrentUser currentUser = TokenManager.GetCurentUserbyToken(HttpContext.Request.Headers); var result = await _inventoryReportService.ExportOpeningTemplate(currentUser); ExportOpeningTemplateVM <MaterialFileTemplate> model = new ExportOpeningTemplateVM <MaterialFileTemplate>(); model.Entitys = result.Data.List == null ? new List <MaterialFileTemplate>() : result.Data.List; model.Columns = new List <string>() { "MaterialCode", "MaterialName", "Spec", "WareName", "WareUnitName" }; model.Titles = new List <string>() { "MaterialCode", "MaterialName", "Spec", "WareName", "WareUnitName" }; model.HeaderText = "期初模板"; model.TableName = "期初模板"; model.FillRow = 1; model.DropDownEntitys = result.Data.WarehouseName; model.DropDownFillStartCell = 3; model.DropDownFillEndCell = 3; model.Path = Path.Combine(AppContext.BaseDirectory, "Template", "ExportOpeningTemplate.xlsx"); Stream stream = ExcelHelp.ExportOpeningTemplate <MaterialFileTemplate>(model); string fileName = "期初模板.xlsx"; Dictionary <string, string> headsSend = new Dictionary <string, string>(); headsSend.Add(TokenConfig.Instace.TokenKey, Request.Headers[TokenConfig.Instace.TokenKey]); var filePath = RestfulApiClient.UploadFile(RestfulApiClient.UplaodUrl, "api/files/upload", headsSend, stream, fileName); return(ResponseUtil <string> .SuccessResult(filePath.ToString())); } catch (Exception ex) { return(ResponseUtil <string> .FailResult(null, ex.ToString())); } }