public Response UploadIForm(IFormFile file, string pcode, string scode) { string outputDirPath = $"/OfficeFiles/"; Response result = new Infrastructure.Response(); var fileName = file.FileName; String suffixName = fileName.Substring(fileName.LastIndexOf(".")); Console.WriteLine(fileName); var newfilename = pcode + scode + suffixName; fileName = $"/UploadFile/{newfilename}"; fileName = _hostingEnvironment.WebRootPath + fileName; using (FileStream fs = System.IO.File.Create(fileName)) { file.CopyTo(fs); fs.Flush(); } Step step = _unitWork.Find <Step>(u => u.ProductCode == pcode && u.Code == scode).FirstOrDefault(); if (suffixName.ToUpper() == ".XLSX" || suffixName.ToUpper() == ".XLS") { ExcelPreview.Priview(fileName, pcode + scode, _hostingEnvironment.WebRootPath + outputDirPath); step.LinkSop = "/OfficeFiles/" + pcode + scode + ".html"; } else if (suffixName.ToUpper() == ".DOC" || suffixName.ToUpper() == ".DOCX") { WordPreview.Priview(fileName, pcode + scode, _hostingEnvironment.WebRootPath + outputDirPath); step.LinkSop = "/OfficeFiles/" + pcode + scode + ".html"; } else { step.LinkSop = "/UploadFile/" + newfilename; }; _app.Update(step); return(result); }
protected void btnExcel_Click(object sender, EventArgs e) { string filePath = Server.MapPath("~") + @"\DemoFiles\Test.xlsx"; ExcelPreview.Priview(this, filePath, outputDirPath); }