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.mzph.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;如何查看 …