惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

博客园 - 冯小磊

女人的面相 只有mdf文件的恢复技术 冒泡,选择,插入,希尔 vb.net c#.net 代码相互转换 [转]C# 参考之转换关键字:operator、explicit与implicit 【转载】SQL查询中区分大小写的方法 Dev里面DataGid控件使用方法之一 对于sql数据库中重复的记录... 白骨精写给孙悟空的绝世情书 DBCC CHECKDB (检查指定数据库中的所有对象的分配和结构完整性) c# 限制窗体 sqlserver附加数据库错误823的解决方案 改变DevExpress控件的字体 按某一字段分组取最大(小)值所在行的数据 mssql1069错误(由于登录失败而无法启动服务)解决方法 C# 判断中文字符(字符串) 函数datediff MSSQL中取字符中的汉字或双字节字符 用SqlCommandBuilder 实现批量更新
(word导出问题)解决:服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))的解决方法
冯小磊 · 2008-07-08 · via 博客园 - 冯小磊

 症状:      生成Word格式的报告,调试过程中总是出现"服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))"的错误
 原因:      代码 WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing,ref Visible), 最后一个参数Visibale设置成false了
 解决方法:Visible=true

using System;
using System.Collections.Generic;
using System.Text;

namespace Business
{
    
public class WordDocument
    
{
        Microsoft.Office.Interop.Word.Application WordApp;
        Microsoft.Office.Interop.Word.Document WordDoc;
        
object SaveChanges = true;
        
object Visible = true;//问题就在这里,改成true后就能正常运行了
        object Nothing = System.Reflection.Missing.Value;
        
object WordDocPath;
        
public WordDocument(string wordDocPath)
        
{
            
this.WordDocPath = wordDocPath;
            
this.Open();
        }

        
private void Open()
        
{
            
if (System.IO.File.Exists(this.WordDocPath.ToString()))
            
{
                System.IO.File.Delete(
this.WordDocPath.ToString());
            }


            WordApp 
= new Microsoft.Office.Interop.Word.ApplicationClass();
            WordDoc 
= WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing,ref Visible);
        }
        
        
public void Append(string Content,int Level)
        
{
           WordDoc.Paragraphs.Last.Range.Text 
= WordDoc.Paragraphs.Last.Range.Text + Content;
            
switch (Level)
            
{
                
case 1:
                    WordDoc.Paragraphs.Last.Range.Font.Bold 
= 3;
                    WordDoc.Paragraphs.Last.Range.Font.Name 
= "宋体";
                    WordDoc.Paragraphs.Last.Range.Font.Size 
= 16;
                    
break;
                
case 2:
                    WordDoc.Paragraphs.Last.Range.Font.Bold 
= 3;
                    WordDoc.Paragraphs.Last.Range.Font.Name 
= "宋体";
                    WordDoc.Paragraphs.Last.Range.Font.Size 
= 14;
                    
break;
                
case 3:
                    WordDoc.Paragraphs.Last.Range.Font.Bold 
= 3;
                    WordDoc.Paragraphs.Last.Range.Font.Name 
= "宋体";
                    WordDoc.Paragraphs.Last.Range.Font.Size 
= 12;
                    
// Content = "    " + Content;
                    break;
                
default:
                    WordDoc.Paragraphs.Last.Range.Font.Bold 
= 0;
                    WordDoc.Paragraphs.Last.Range.Font.Size 
= 12;
                    WordDoc.Paragraphs.Last.Range.Font.Name 
= "宋体";
                    
//Content = "    " + Content;
                    break;
            }

             
//*/
         
        }

        
public void SaveDoc()
        
{
            WordDoc.SaveAs(
ref this.WordDocPath,ref Nothing,ref Nothing,ref Nothing,
                
ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,
                
ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing);
        }

        
public void CloseDoc()
        
{
            WordDoc.Close(
ref SaveChanges, ref Nothing, ref Nothing);
            WordApp.Quit(
ref SaveChanges, ref Nothing, ref Nothing);
        }

       
private void Create(string wordDocPath)
        
{
            System.IO.FileInfo file 
= new System.IO.FileInfo(wordDocPath);
            file.Create();
        }

    }

}