C#Word轉Html的類

C#Word轉Html的類



/**//********************************************************************
????created:????2007/11/02
????created:????2:11:2007???23:13
????filename:?????D:C#程序練習WordToChmWordToHtml.cs
????file?path:????D:C#程序練習WordToChm
????file?base:????WordToHtml
????file?ext:????cs
????author:????????凌劍?Bujiwu
????
????purpose:????將Word文件轉化為Html文件
********************************************************************
*/

using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.IO;

namespace?CreateWordToHtmlFileSpace
...{
????
class?WordToHtml
????
...{
????????
public?static?void?CreateWordToHtmlFile(string?WordFileDir)
????????
...{
????????????DealWithWordFile(WordFileDir);
????????}

????????
//搜索WordFileDir在的*.doc文件
????????private?static?void?DealWithWordFile(string?WordFileDir)
????????
...{
????????????
//創建數組保存源文件夾下的文件名
????????????string[]?strFiles?=?Directory.GetFiles(WordFileDir,?"*.doc");
????????????
for?(int?i?=?0;?i?<?strFiles.Length;?i++)
????????????
...{
????????????????WordToHtmlFile(strFiles[i]);
????????????}


????????????DirectoryInfo?dirInfo?
=?new?DirectoryInfo(WordFileDir);
????????????
//取得源文件夾下的所有子文件夾名稱
????????????DirectoryInfo[]?ZiPath?=?dirInfo.GetDirectories();
????????????
for?(int?j?=?0;?j?<?ZiPath.Length;?j++)
????????????
...{
????????????????
//獲取所有子文件夾名
????????????????string?strZiPath?=?WordFileDir?+?"/"?+?ZiPath[j].ToString();
????????????????
//把得到的子文件夾當成新的源文件夾,從頭開始新一輪的搜索
????????????????DealWithWordFile(strZiPath);
????????????}

????????}

????????
//轉化
????????private?static?void?WordToHtmlFile(string?WordFilePath)
????????
...{
????????????
try
????????????
...{
????????????????Microsoft.Office.Interop.Word.Application?newApp?
=?new?Microsoft.Office.Interop.Word.Application();
????????????????
//?指定原文件和目標文件
????????????????object?Source?=?WordFilePath;
????????????????
string?SaveHtmlPath?=?WordFilePath.Substring(0,?WordFilePath.Length?-?3)?+?"html";
????????????????
object?Target?=?SaveHtmlPath;

????????????????
//?缺省參數??
????????????????object?Unknown?=?Type.Missing;

????????????????
//為了保險,只讀方式打開
????????????????object?readOnly?=?true;

????????????????
//?打開doc文件
????????????????Microsoft.Office.Interop.Word.Document?doc?=?newApp.Documents.Open(ref?Source,?ref?Unknown,
?????????????????????
ref?readOnly,?ref?Unknown,?ref?Unknown,
?????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
?????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
?????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
?????????????????????
ref?Unknown,?ref?Unknown);

????????????????
//?指定另存為格式(rtf)
????????????????object?format?=?Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
????????????????
//?轉換格式
????????????????doc.SaveAs(ref?Target,?ref?format,
????????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
????????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
????????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
????????????????????????
ref?Unknown,?ref?Unknown,?ref?Unknown,
????????????????????????
ref?Unknown,?ref?Unknown);

????????????????
//?關閉文檔和Word程序
????????????????doc.Close(ref?Unknown,?ref?Unknown,?ref?Unknown);
????????????????newApp.Quit(
ref?Unknown,?ref?Unknown,?ref?Unknown);
????????????}

????????????
catch(Exception?e)
????????????
...{
????????????????System.Windows.Forms.MessageBox.Show(e.Message);?
????????????}

????????}


????}

}

楊航收集技術資料,分享給大家



本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388264.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388264.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388264.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

分庫分表的幾種常見形式以及可能遇到的難題

前言 在談論數據庫架構和數據庫優化的時候&#xff0c;我們經常會聽到“分庫分表”、“分片”、“Sharding”…這樣的關鍵詞。讓人感到高興的是&#xff0c;這些朋友所服務的公司業務量正在&#xff08;或者即將面臨&#xff09;高速增長&#xff0c;技術方面也面臨著一些挑戰。…

iOS 鑰匙串的基本使用

級別&#xff1a; ★☆☆☆☆ 標簽&#xff1a;「鑰匙串」「keychain」「iOS」 作者&#xff1a; WYW 審校&#xff1a; QiShare團隊 前言 &#xff1a; 項目中有時會需要存儲敏感信息&#xff08;如密碼、密鑰等&#xff09;&#xff0c;蘋果官方提供了一種存儲機制--鑰匙串&a…

線性回歸和將線擬合到數據

Linear Regression is the Supervised Machine Learning Algorithm that predicts continuous value outputs. In Linear Regression we generally follow three steps to predict the output.線性回歸是一種監督機器學習算法&#xff0c;可預測連續值輸出。 在線性回歸中&…

Spring Boot MyBatis配置多種數據庫

mybatis-config.xml是支持配置多種數據庫的&#xff0c;本文將介紹在Spring Boot中使用配置類來配置。 1. 配置application.yml # mybatis配置 mybatis:check-config-location: falsetype-aliases-package: ${base.package}.modelconfiguration:map-underscore-to-camel-case: …

小米盒子4 拆解圖解_我希望當我開始學習R時會得到的盒子圖解指南

小米盒子4 拆解圖解Customizing a graph to transform it into a beautiful figure in R isn’t alchemy. Nonetheless, it took me a lot of time (and frustration) to figure out how to make these plots informative and publication-quality. Rather than hoarding this …

組態王仿真隨機數

1、新建IO設備&#xff0c;選擇PLC---亞控---仿真PLC&#xff0c;一直“下一步”。 2、在“數據詞典”中新建變量“Tag1”&#xff0c;雙擊Tag1&#xff0c;變量類型選&#xff1a;I/O實數&#xff1b;初始值設為&#xff1a;0.6&#xff1b;最小值設為&#xff1a;0.5&#xf…

藍牙一段一段_不用擔心,它在那里存在了一段時間

藍牙一段一段You’re sitting in a classroom. You look around and see your friends writing something down. It seems they are taking the exam, and they know all the answers (even Johnny who, how to say it… wasn’t the brilliant one). You realize that your ex…

Linux基礎命令---ifup、ifdown

ifupifup指令用來啟動網絡接口設備&#xff0c;設備必須是定義在“/etc/sysconfig/network-scripts/ifcfg-ethX”或者“/etc/sysconfig/network”的文件。這些腳本通常使用一個參數&#xff1a;配置的名稱(例如eth0)。在引導序列中&#xff0c;使用“boot”的第二個參數調用它們…

OllyDBG 入門之四--破解常用斷點設

OllyDBG 入門之四--破解常用斷點&#xff08;轉&#xff09; 軟件漢化2010-07-08 16:25:23 閱讀76評論0 字號&#xff1a;大中小 訂閱 bpx hmemcpy 破解萬能斷點&#xff0c;攔截內存拷貝動作 bpx Lockmytask 當你用其它斷點都無效時可以試一下&#xff0c;這個斷點攔截…

POJ1204 Word Puzzles

傳送門 這題果然是AC自動機的大好題&#xff01; 題目的大意是&#xff0c;給定一個l*c的大網格&#xff0c;每個格子里有一個字符&#xff0c;每個格子可以向八個方向形成字符串&#xff0c;問給定的字符串在哪里能被匹配以及在網格中出現的方向&#xff08;A代表北&#xff0…

普通話測試系統_普通話

普通話測試系統Traduzido/adaptado do original por Vincius Barqueiro a partir do texto original “Writing Alt Text for Data Visualization”, escrito por Amy Cesal e publicado no blog Nightingale.Traduzido / adaptado由 VinciusBarqueiro 提供原始 文本“為數據可…

Mac OS 被XCode搞到無法正常開機怎么辦?

Mac OS 被XCode搞到無法正常開機怎么辦&#xff1f; 第一天拿到這臺air的時候&#xff0c;迫不及待地把從別處搜集來的XCode 3.2.5iOS SDK 4.1的dmg安裝了上來&#xff0c;結果系統直接崩潰&#xff0c;再開機就不能正常開機&#xff0c;總是碰到kernel panic。這不坑爹嗎…… …

美國隊長3:內戰_隱藏的寶石:尋找美國最好的秘密線索

美國隊長3:內戰There are plenty of reasons why one would want to find solitude in the wilderness, from the therapeutic effects of being immersed in nature, to not wanting to contribute to trail degradation and soil erosion on busier trails.人們有很多理由想要…

Java入門第三季——Java中的集合框架(中):MapHashMap

1 package com.imooc.collection;2 3 import java.util.HashSet;4 import java.util.Set;5 6 /**7 * 學生類8 * author Administrator9 * 10 */ 11 public class Student { 12 13 public String id; 14 15 public String name; 16 17 public Set<…

【譯】 WebSocket 協議第八章——錯誤處理(Error Handling)

概述 本文為 WebSocket 協議的第八章&#xff0c;本文翻譯的主要內容為 WebSocket 錯誤處理相關內容。 錯誤處理&#xff08;協議正文&#xff09; 8.1 處理 UTF-8 數據錯誤 當終端按照 UTF-8 的格式來解析一個字節流&#xff0c;但是發現這個字節流不是 UTF-8 編碼&#xff0c…

升級xcode5.1 iOS 6.0后以前的橫屏項目 變為了豎屏

升級xcode5.1 iOS 6.0后以前的橫屏項目 變為了豎屏&#xff0c;以下為解決辦法&#xff1a; 在AppDelegate 的初始化方法 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中 將 [window addSubview: viewCon…

動漫數據推薦系統

Simple, TfidfVectorizer and CountVectorizer recommendation system for beginner.簡單的TfidfVectorizer和CountVectorizer推薦系統&#xff0c;適用于初學者。 目標 (The Goal) Recommendation system is widely use in many industries to suggest items to customers. F…

Wait Event SQL*Net more data to client

oracle 官方給的說法是 C.3.152 SQL*Net more data to client The server process is sending more data/messages to the client. The previous operation to the client was also a send. Wait Time: The actual time it took for the send to complete 意味著server process…

1.3求根之牛頓迭代法

目錄 目錄前言&#xff08;一&#xff09;牛頓迭代法的分析1.定義2.條件3.思想4.誤差&#xff08;二&#xff09;代碼實現1.算法流程圖2.源代碼&#xff08;三&#xff09;案例演示1.求解&#xff1a;\(f(x)x^3-x-10\)2.求解&#xff1a;\(f(x)x^2-1150\)3.求解&#xff1a;\(f…

libzbar.a armv7

楊航最近在學IOS&#xfeff;&#xfeff; http://download.csdn.net/download/lzwxyz/5546365 我現在用的是這個&#xff1a;http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/ 點它的HERE開始下載 下載的libzbar.a庫&#xff0c;如何查看 …