Example #1
0
        public static string ConvertExelToPDF(string b_file)
        {
            //b_file = HttpContext.Current.Server.MapPath("~") + b_file;
            string partShare       = WebConfigurationManager.AppSettings["ServerLinkFile"];
            string LinkServerLocal = WebConfigurationManager.AppSettings["ServerLocal"];
            util   a = new util();

            if (!File.Exists(b_file))
            {
                return(string.Empty);
            }
            string ex = ".xls";

            if (b_file.IndexOf(".xlsx") > 0)
            {
                ex = ".xlsx";
            }
            string b_out = b_file.Replace(ex, ".pdf");

            if (File.Exists(b_out))
            {
                //b_out = b_out.Replace(HttpContext.Current.Server.MapPath("~"), string.Empty);
                if (!string.IsNullOrEmpty(LinkServerLocal))
                {
                    b_out = b_out.Replace(LinkServerLocal, string.Empty);
                }
                else
                {
                    b_out = b_out.Replace("////" + partShare, string.Empty);
                }
                return(b_out);
            }

            a.ConvertXLSToPdf(b_file, b_out, System.Drawing.Printing.PaperKind.A3);
            if (!string.IsNullOrEmpty(LinkServerLocal))
            {
                b_out = b_out.Replace(LinkServerLocal, string.Empty);
            }
            else
            {
                b_out = b_out.Replace("////" + partShare, string.Empty);
            }
            //b_out = b_out.Replace(HttpContext.Current.Server.MapPath("~"), string.Empty);
            return(b_out);
        }