Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 日韩欧美亚洲乱码中文字幕,91麻豆国产极品在线观看洋子,免费播放一区二区三区

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          開源easyHtml-導出html表格文件

          接上篇文章,導出html文件,我對這部分代碼進行優化,提交到github上,為初始版本,后面根據用戶需求與討論,會不斷更新優化功能

          介紹

          • 功能

          導出Html 表格文件,簡單易用

          • 地址

          https://github.com/CollectBugs/EasyHtml

          • 項目展示



          總結

          開發此項目的靈感來源于一次項目開發,發現導出html表格文件需求,比較常見,市面上開源、成熟、免費的方案沒有,如果每一家公司,都從零開始開發,耗時又費力,導致開發周期變長,不如大家開源共建此項目,讓后來人站在巨人的肩膀上進行開發與維護,共享資源,其樂而不為,希望大家多多給與關注與討論哦!

          每天不斷更,精彩不停止,明天見,我是行者

          記得留個關注、點贊、評論喲,讓我們一起去看星辰大海,品味代碼人生

          、nuget 引用

          Select.HtmlToPdf

          2、方法

          • using SelectPdf;using System.Collections.Specialized;using System.IO;using System.Web;
            namespace BQoolCommon.Helpers.File{ public class WebToPdf { public WebToPdf() { //SelectPdf.GlobalProperties.LicenseKey = "your-license-key"; }
            /// <summary> /// 將 Html 轉成 PDF,並儲存成檔案 /// </summary> /// <param name="html">html</param> /// <param name="fileName">絕對路徑</param> public void SaveToFileByHtml(string html, string fileName) { var doc = SetPdfDocument(html); doc.Save(fileName); }
            /// <summary> /// 傳入 Url 轉成 PDF,並儲存成檔案 /// </summary> /// <param name="url">url</param> /// <param name="fileName">絕對路徑</param> /// <param name="httpCookies">Cookies</param> public void SaveToFileByUrl(string url, string fileName, NameValueCollection httpCookies) { var doc = SetPdfDocument(url, httpCookies); doc.Save(fileName); }
            /// <summary> /// 將 Html 轉成 PDF,並輸出成 byte[] 格式 /// </summary> /// <param name="html">html</param> /// <returns></returns> public byte[] GetFileByteByHtml(string html) { var doc = SetPdfDocument(html); return doc.Save(); }
            /// <summary> /// 傳入 Url 轉成 PDF,並輸出成 byte[] 格式 /// </summary> /// <param name="url">url</param> /// <param name="httpCookies">Cookies</param> /// <returns></returns> public byte[] GetFileByteByUrl(string url, NameValueCollection httpCookies) { var doc = SetPdfDocument(url, httpCookies); return doc.Save(); }
            /// <summary> /// 將 Html 轉成 PDF,並輸出成 Stream 格式 /// </summary> /// <param name="html">html</param> /// <returns></returns> public Stream GetFileStreamByHtml(string html) { var doc = SetPdfDocument(html); var pdfStream = new MemoryStream();
            doc.Save(pdfStream); pdfStream.Position = 0;
            return pdfStream; }
            /// <summary> /// 傳入 Url 轉成 PDF,並輸出成 Stream 格式 /// </summary> /// <param name="html">html</param> /// <returns></returns> public Stream GetFileStreamByUrl(string url, NameValueCollection httpCookies) { var doc = SetPdfDocument(url, httpCookies); var pdfStream = new MemoryStream();
            doc.Save(pdfStream); pdfStream.Position = 0;
            return pdfStream; }
            private PdfDocument SetPdfDocument(string html) { var converter = new HtmlToPdf();
            converter.Options.WebPageWidth = 1200; html = HttpUtility.HtmlDecode(html);
            return converter.ConvertHtmlString(html); }
            private PdfDocument SetPdfDocument(string url, NameValueCollection httpCookies) { var converter = new HtmlToPdf(); converter.Options.WebPageWidth = 1200;
            if (httpCookies != && httpCookies.Count != 0) { converter.Options.HttpCookies.Add(httpCookies); }
            return converter.ConvertUrl(url); }
            }}

          目中用到需要將頁面數據導出 就想到了IE的直接導出。

          將用到的示例給大家分享一下:

          //將表格中的數據導出到excel中

          function exportDataToExcel(tid){

          var curTbl = $('#tid');

          var oXLn;

          try{

          oXLn = new ActiveXObject("Excel.Application"); //創建對象excel

          }catch(e){

          alert("無法啟動Excel!\n\n如果您確信您的電腦中已經安裝了Excel,"+"那么請調整IE的安全級別。\n\n具體操作:\n\n"+"工具 → Internet選項 → 安全 → 自定義級別 → 對沒有標記為安全的ActiveX進行初始化和腳本運行 → 啟用");

          return false;

          }

          var oWBs = oXLn.Workbooks.Add(); //獲取workbook對象

          var oSheet1 = oWBs.ActiveSheet;//激活當前sheet

          var sel = document.body.createTextRange();

          sel.moveToElementText(curTbl); //把表格中的內容移到TextRange中

          sel.select(); //全選TextRange中內容

          sel.execCommand("Copy");//復制TextRange中內容

          oSheet1.Paste();//粘貼到活動的EXCEL中

          oXLn.Visible = true; //設置excel可見屬性

          var fname = oXLn.Application.GetSaveAsFilename("將table導出到excel.xls", "Excel Spreadsheets (*.xls), *.xls");

          oWBs.SaveAs(fname);

          oWBs.Close();

          oXLn.nQuit();

          }

          注意:1.電腦必須安裝微軟的excel。

          2.需要將瀏覽器的active控件設置為啟用。


          主站蜘蛛池模板: 好湿好大硬得深一点动态图91精品福利一区二区| 国产伦精品一区二区三区视频猫咪| 精品一区二区三区免费观看| 精品人妻码一区二区三区| 中文字幕日韩欧美一区二区三区| 精品亚洲综合在线第一区| AV怡红院一区二区三区| 相泽南亚洲一区二区在线播放| 精品国产a∨无码一区二区三区| 中文字幕一区二区人妻| 中文字幕一区精品| 精品国产一区二区三区AV性色| 无码少妇丰满熟妇一区二区| 精品无码一区二区三区亚洲桃色| 熟女大屁股白浆一区二区| V一区无码内射国产| 三上悠亚日韩精品一区在线| 亚洲高清偷拍一区二区三区| 一区二区三区电影网| 人妻内射一区二区在线视频| 国产一国产一区秋霞在线观看| 亚洲AV无码一区二区三区牲色 | 麻豆高清免费国产一区| 无码精品人妻一区二区三区免费看| 99久久精品国产免看国产一区| 相泽亚洲一区中文字幕| 久久国产精品免费一区二区三区| 一区二区三区久久精品| 国产91一区二区在线播放不卡 | 久久一区二区明星换脸| 久久久精品人妻一区二区三区 | 久久久无码一区二区三区| 久久久av波多野一区二区| 无码人妻一区二区三区免费 | 久久久91精品国产一区二区| 一区二区三区四区精品视频| 麻豆一区二区在我观看| 成人免费视频一区| 久久精品国产一区二区三区不卡 | 秋霞日韩一区二区三区在线观看 | 日韩一区二区三区视频|