日期:2014-05-16  浏览次数:20420 次

如何用C#将html保存为word文档, 注:不是手工操作, 用代码来完成
如题, 有什么好办法吗?

------解决方案--------------------
http://blog.csdn.net/educast/article/details/4420111

希望对你有帮助。
------解决方案--------------------
msdn search office automation
------解决方案--------------------
找到解决办法了

还是我刚才的代码

/// <summary>
    private static StreamReader sr;
    private static StreamWriter sw;
    /// 读取文件
    /// </summary>
    /// <param name="Path">文件路径</param>
    /// <param name="Coding">文件编码</param>
    /// <returns></returns>
    public static string Reader(string Path, string Coding)
    {
        string str = "";
        if (File.Exists(Path))
        {
            try
            {
                sr = new StreamReader(Path, Encoding.GetEncoding(Coding));
                str = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }

        return str;
    }

    /// <summary>
    /// 写入文件
    /// </summary>
    /// <param name="Path">文件路径</param>
    /// <param name="Text">写入内容</param>
    /// <param name="Coding">文件编码</param>
    public static void Writer(string Path, string Text, string Coding)
    {
        if (File.Exists(Path))
        {
            Delete(Path);
        }
        try
        {
            sw = new StreamWriter(Path, false, Encoding.GetEncoding(Coding));
            sw.WriteLine(Text);
            sw.Flush();
     &nbs