<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      代碼改變世界

      Office系列在線預覽

      2011-08-10 16:42  【當耐特】  閱讀(17106)  評論(25)    收藏  舉報

      最近客戶有個需求,需要在線預覽PPT、Excel、Word,開始打算用第三方組建去讀取 office系列,然后生成html,這樣的話樣式相當于丟了,只剩下數據,而且第三方組件對office版本支持不夠完善,最關鍵的是還是樣式丟了!

      最后決定,用戶在上傳的過程中調用office API里面的saveAs,自動生成了靜態html,預覽的時候就直接訪問的該html頁面。

      [a].WordToHtml

       1  public static string WordToHtml(string path, string savePath, string wordFileName)
       2         {
       3 
       4             //在此處放置用戶代碼以初始化頁面
       5             Microsoft.Office.Interop.Word.Application word = new Word.Application();
       6 
       7             Type wordType = word.GetType();
       8 
       9             Word.Documents docs = word.Documents;
      10 
      11             //打開文件
      12             Type docsType = docs.GetType();
      13             Word.Document doc = (Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { path, truetrue });
      14 
      15             //轉換格式,另存為
      16             Type docType = doc.GetType();
      17 
      18             string wordSaveFileName = savePath;
      19 
      20             string strSaveFileName = savePath+wordFileName + ".html";
      21 
      22             object saveFileName = (object)strSaveFileName;
      23 
      24             docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML });
      25 
      26             docType.InvokeMember("Close", System.Reflection.BindingFlags.InvokeMethod, null, doc, null);
      27 
      28             //退出 Word
      29             wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
      30 
      31             return saveFileName.ToString();
      32         }

       

      [b].ExcelToHtml

       1  public static void ExcelToHtml(string path,string savePath, string wordFileName)
       2         {
       3             string str = string.Empty;
       4             Microsoft.Office.Interop.Excel.Application repExcel = new Microsoft.Office.Interop.Excel.Application();
       5             Microsoft.Office.Interop.Excel.Workbook workbook = null;
       6             Microsoft.Office.Interop.Excel.Worksheet worksheet = null;
       7             workbook = repExcel.Application.Workbooks.Open(path, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
       8             worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];
       9             object htmlFile =savePath+wordFileName+ ".html";
      10             object ofmt = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
      11             workbook.SaveAs(htmlFile, ofmt, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
      12             object osave = false;
      13             workbook.Close(osave, Type.Missing, Type.Missing);
      14             repExcel.Quit();
      15            
      16         }

       

      [c].PPTToHtml

       public static  void PPTToHtml(string path, string savePath, string wordFileName)
              {
                  Microsoft.Office.Interop.PowerPoint.Application ppApp 
      = new Microsoft.Office.Interop.PowerPoint.Application();
                  
      string strSourceFile = path;
                  
      string strDestinationFile = savePath+wordFileName+".html";
                  Microsoft.Office.Interop.PowerPoint.Presentation prsPres 
      = ppApp.Presentations.Open(strSourceFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                  prsPres.SaveAs(strDestinationFile, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTrue);
                  prsPres.Close();
                  ppApp.Quit();

              }

       

      當完成該功能的時候,上帝那邊傳來噩耗,他們表示不愿意在服務器上安裝office,所以我們繼續尋找解決方案······

       

      主站蜘蛛池模板: 蜜桃成熟色综合久久av| 国产揄拍国产精品| аⅴ天堂中文在线网| 国产成人a∨激情视频厨房| 毛茸茸性xxxx毛茸茸毛茸茸| 久久精品国产午夜福利伦理| 又粗又硬又黄a级毛片| 亚洲欧洲av人一区二区| 欧美牲交a欧美牲交aⅴ图片| 亚洲日韩性欧美中文字幕| 亚洲综合一区二区三区视频| 国产精品中文字幕免费| 视频二区中文字幕在线| 中文字幕乱码熟妇五十中出 | 亚洲无av在线中文字幕| 国产超高清麻豆精品传媒麻豆精品 | 日韩av在线不卡一区二区| 亚洲午夜成人精品电影在线观看| 日本一区二区不卡精品| 国产成人精品亚洲日本片| 国内自拍小视频在线看| 国产成人欧美一区二区三区在线| 无套中出极品少妇白浆| 成熟熟女国产精品一区二区| 欧美乱妇高清无乱码免费| 国产成人8X人网站视频| 久久99精品国产麻豆宅宅| 双乳奶水饱满少妇呻吟免费看| 特级做a爰片毛片免费看无码| 国产亚洲精品aaaa片app| 日韩一区二区三区亚洲一| 中文字幕日韩人妻一区| 鲁丝一区二区三区免费| 高清在线一区二区三区视频| 又大又紧又粉嫩18p少妇| 国产免费午夜福利片在线| 深夜在线观看免费av| 精品国产精品午夜福利| 久久亚洲女同第一区综合| 国产日韩另类综合11页| 日本三级香港三级人妇99|