bklLiudl
2024-07-23 675b8bcc4a3630d95e3d0b97d933e63442075ecb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Common;
using System.Web.Mvc;
using Lib;
 
namespace wms.Areas.SyetemSet.Controllers
{
    public class OfficeViewController : AjaxPage
    {
        #region Index页面
        /// <summary>
        /// Index页面
        /// </summary>
        /// <param name="url">例:/uploads/......XXX.xls</param>
        public ActionResult Index(string url)
        {
           
            string physicalPath = Server.MapPath(Server.UrlDecode(url));
            string extension = System.IO.Path.GetExtension(physicalPath);
            string htmlUrl = "";
            switch (extension.ToLower())
            {
                case ".xls":
                case ".xlsx":
                    htmlUrl = OfficeView. PreviewExcel(physicalPath, url);
                    break;
                case ".doc":
                case ".docx":
                    htmlUrl = OfficeView.PreviewWord(physicalPath, url);
                    break;
                case ".txt":
                    htmlUrl = OfficeView.PreviewTxt(physicalPath, url);
                    break;
                case ".pdf":
                    htmlUrl = OfficeView.PreviewPdf(physicalPath, url);
                    break;
            }
            return Redirect(Url.Content(htmlUrl));
        }
        #endregion
       
    }
}