Microsoft.Office.Interop.Word 创建word

转载:http://www.cnblogs.com/chenbg2001/archive/2010/03/14/1685746.html

功能总结或者完善。

一、添加页眉

using  System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word; namespace WordCreateDLL
{
public class AddHeader
{
public static void AddSimpleHeader(Application WordApp, string HeaderText)
{
//添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
WordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;//设置左对齐
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
}
public static void AddSimpleHeader(Application WordApp, string HeaderText, WdParagraphAlignment wdAlign)
{
//添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
//WordApp.Selection.Font.Color = WdColor.wdColorDarkRed;//设置字体颜色
WordApp.Selection.ParagraphFormat.Alignment = wdAlign;//设置左对齐
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
}
public static void AddSimpleHeader(Application WordApp, string HeaderText, WdParagraphAlignment wdAlign,WdColor fontcolor, float fontsize)
{
//添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
WordApp.Selection.Font.Color =fontcolor;//设置字体颜色
WordApp.Selection.Font.Size = fontsize;//设置字体大小
WordApp.Selection.ParagraphFormat.Alignment = wdAlign;//设置对齐方式
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
} }
}

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word;
namespace WordCreateDLL
{ public class AddHeader { public static void
AddSimpleHeader(Application WordApp,string HeaderText) { //添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
WordApp.Selection.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphLeft;//设置左对齐
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument; }
public static void AddSimpleHeader(Application WordApp, string
HeaderText, WdParagraphAlignment wdAlign) { //添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
//WordApp.Selection.Font.Color = WdColor.wdColorDarkRed;//设置字体颜色
WordApp.Selection.ParagraphFormat.Alignment = wdAlign;//设置左对齐
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument; }
public static void AddSimpleHeader(Application WordApp, string
HeaderText, WdParagraphAlignment wdAlign,WdColor fontcolor,float
fontsize) { //添加页眉 WordApp.ActiveWindow.View.Type =
WdViewType.wdOutlineView; WordApp.ActiveWindow.View.SeekView =
WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
WordApp.Selection.Font.Color =fontcolor;//设置字体颜色
WordApp.Selection.Font.Size = fontsize;//设置字体大小
WordApp.Selection.ParagraphFormat.Alignment = wdAlign;//设置对齐方式
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument; } }
}

 

二、插入图片

 

using  System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word; namespace WordCreateDLL
{
public class AddPic
{
public static void AddSimplePic(Document WordDoc, string FName, float Width, float Height, object An, WdWrapType wdWrapType)
{
//插入图片
string FileName = @FName; //图片所在路径
object LinkToFile = false ;
object SaveWithDocument = true ;
object Anchor = An;
WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
WordDoc.Application.ActiveDocument.InlineShapes[1].Width = Width;//图片宽度
WordDoc.Application.ActiveDocument.InlineShapes[1].Height = Height;//图片高度
//将图片设置为四周环绕型
Microsoft.Office.Interop.Word.Shape s = WordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape();
s.WrapFormat.Type = wdWrapType;
} }
}

 

using
System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word;
namespace WordCreateDLL
{ public class AddPic { public static void AddSimplePic(Document
WordDoc, string FName, float Width, float Height, object An, WdWrapType
wdWrapType) { //插入图片 string FileName = @FName;//图片所在路径 object
LinkToFile = false; object SaveWithDocument = true; object Anchor = An;
WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName,
ref LinkToFile, ref SaveWithDocument, ref Anchor);
WordDoc.Application.ActiveDocument.InlineShapes[1].Width = Width;//图片宽度
WordDoc.Application.ActiveDocument.InlineShapes[1].Height =
Height;//图片高度 //将图片设置为四周环绕型 Microsoft.Office.Interop.Word.Shape s =
WordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape();
s.WrapFormat.Type = wdWrapType; } }
}

 

三、插入表格

 

using  System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word; namespace WordCreateDLL
{
public class AddTable
{
public static void AddSimpleTable(Application WordApp, Document WordDoc, int numrows, int numcolumns, WdLineStyle outStyle, WdLineStyle intStyle)
{
Object Nothing = System.Reflection.Missing.Value;
//文档中创建表格
Microsoft.Office.Interop.Word.Table newTable = WordDoc.Tables.Add(WordApp.Selection.Range, numrows, numcolumns, ref Nothing, ref Nothing);
//设置表格样式
newTable.Borders.OutsideLineStyle = outStyle;
newTable.Borders.InsideLineStyle = intStyle;
newTable.Columns[1].Width = 100f;
newTable.Columns[2].Width = 220f;
newTable.Columns[3].Width = 105f; //填充表格内容
newTable.Cell(1, 1).Range.Text = "产品详细信息表" ;
newTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
//合并单元格
newTable.Cell(1, 1).Merge(newTable.Cell(1, 3));
WordApp.Selection.Cells.VerticalAlignment =WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中
WordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;//水平居中 //填充表格内容
newTable.Cell(2, 1).Range.Text = "产品基本信息" ;
newTable.Cell(2, 1).Range.Font.Color =WdColor.wdColorDarkBlue;//设置单元格内字体颜色
//合并单元格
newTable.Cell(2, 1).Merge(newTable.Cell(2, 3));
WordApp.Selection.Cells.VerticalAlignment =WdCellVerticalAlignment.wdCellAlignVerticalCenter; //填充表格内容
newTable.Cell(3, 1).Range.Text = "品牌名称:" ;
newTable.Cell(3, 2).Range.Text = "品牌名称:" ;
//纵向合并单元格
newTable.Cell(3, 3).Select();//选中一行
object moveUnit = WdUnits.wdLine;
object moveCount = 5;
object moveExtend = WdMovementType.wdExtend;
WordApp.Selection.MoveDown(ref moveUnit, ref moveCount, ref moveExtend);
WordApp.Selection.Cells.Merge(); //插入图片
string FileName = @ "C:\1.jpg" ; //图片所在路径
object Anchor = WordDoc.Application.Selection.Range;
float Width = 200f; //图片宽度
float Height = 200f; //图片高度 //将图片设置为四周环绕型
WdWrapType wdWrapType = Microsoft.Office.Interop.Word.WdWrapType.wdWrapSquare;
AddPic.AddSimplePic(WordDoc, FileName, Width, Height, Anchor, wdWrapType); newTable.Cell(12, 1).Range.Text = "产品特殊属性" ;
newTable.Cell(12, 1).Merge(newTable.Cell(12, 3));
//在表格中增加行
WordDoc.Content.Tables[1].Rows.Add(ref Nothing);
} }
}

 

using
System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word;
namespace WordCreateDLL
{ public class AddTable { public static void AddSimpleTable(Application
WordApp, Document WordDoc, int numrows, int numcolumns, WdLineStyle
outStyle, WdLineStyle intStyle) { Object Nothing =
System.Reflection.Missing.Value; //文档中创建表格
Microsoft.Office.Interop.Word.Table newTable =
WordDoc.Tables.Add(WordApp.Selection.Range, numrows, numcolumns, ref
Nothing, ref Nothing); //设置表格样式 newTable.Borders.OutsideLineStyle =
outStyle; newTable.Borders.InsideLineStyle = intStyle;
newTable.Columns[1].Width = 100f; newTable.Columns[2].Width = 220f;
newTable.Columns[3].Width = 105f; //填充表格内容 newTable.Cell(1,
1).Range.Text = "产品详细信息表"; newTable.Cell(1, 1).Range.Bold =
2;//设置单元格中字体为粗体 //合并单元格 newTable.Cell(1, 1).Merge(newTable.Cell(1, 3));
WordApp.Selection.Cells.VerticalAlignment
=WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中
WordApp.Selection.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter;//水平居中 //填充表格内容
newTable.Cell(2, 1).Range.Text = "产品基本信息"; newTable.Cell(2,
1).Range.Font.Color =WdColor.wdColorDarkBlue;//设置单元格内字体颜色 //合并单元格
newTable.Cell(2, 1).Merge(newTable.Cell(2, 3));
WordApp.Selection.Cells.VerticalAlignment
=WdCellVerticalAlignment.wdCellAlignVerticalCenter; //填充表格内容
newTable.Cell(3, 1).Range.Text = "品牌名称:"; newTable.Cell(3,
2).Range.Text = "品牌名称:"; //纵向合并单元格 newTable.Cell(3, 3).Select();//选中一行
object moveUnit = WdUnits.wdLine; object moveCount = 5; object
moveExtend = WdMovementType.wdExtend; WordApp.Selection.MoveDown(ref
moveUnit, ref moveCount, ref moveExtend);
WordApp.Selection.Cells.Merge(); //插入图片 string FileName =
@"C:\1.jpg";//图片所在路径 object Anchor =
WordDoc.Application.Selection.Range; float Width = 200f;//图片宽度 float
Height = 200f;//图片高度 //将图片设置为四周环绕型 WdWrapType wdWrapType =
Microsoft.Office.Interop.Word.WdWrapType.wdWrapSquare;
AddPic.AddSimplePic(WordDoc, FileName, Width, Height, Anchor,
wdWrapType); newTable.Cell(12, 1).Range.Text = "产品特殊属性";
newTable.Cell(12, 1).Merge(newTable.Cell(12, 3)); //在表格中增加行
WordDoc.Content.Tables[1].Rows.Add(ref Nothing); } }
}

 

四、插入chart

using  System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Graph;
using System.Windows.Forms;
using System.Drawing; namespace WordCreateDLL
{
public class AddChart
{
public static void AddSimpleChart(Document WordDoc, Word.Application WordApp, Object oEndOfDoc, string [,]data)
{
//插入chart
object oMissing = System.Reflection.Missing.Value;
Word.InlineShape oShape;
object oClassType = "MSGraph.Chart.8" ;
Word.Range wrdRng = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing,
ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing); //Demonstrate use of late bound oChart and oChartApp objects to
//manipulate the chart object with MSGraph.
object oChart;
object oChartApp;
oChart = oShape.OLEFormat.Object;
oChartApp = oChart.GetType().InvokeMember("Application" ,BindingFlags.GetProperty, null , oChart, null ); //Change the chart type to Line.
object [] Parameters = new Object[1];
Parameters[0] = 4; //xlLine = 4
oChart.GetType().InvokeMember("ChartType" , BindingFlags.SetProperty,
null , oChart, Parameters); Chart objChart = (Chart)oShape.OLEFormat.Object;
objChart.ChartType = XlChartType.xlColumnClustered; //绑定数据
DataSheet dataSheet;
dataSheet = objChart.Application.DataSheet;
int rownum=data.GetLength(0);
int columnnum=data.GetLength(1);
for ( int i=1;i<=rownum;i++ )
for ( int j = 1; j <= columnnum; j++)
{
dataSheet.Cells[i,j] =data[i-1,j-1]; } objChart.Application.Update();
oChartApp.GetType().InvokeMember("Update" ,
BindingFlags.InvokeMethod, null , oChartApp, null );
oChartApp.GetType().InvokeMember("Quit" ,
BindingFlags.InvokeMethod, null , oChartApp, null ); //设置大小
oShape.Width = WordApp.InchesToPoints(6.25f);
oShape.Height = WordApp.InchesToPoints(3.57f); }
}
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Graph;
using System.Windows.Forms;
using System.Drawing;
namespace WordCreateDLL
{
public class AddChart
{
public static void AddSimpleChart(Document WordDoc, Word.Application WordApp, Object oEndOfDoc, string [,]data)
{
//插入chart
object oMissing = System.Reflection.Missing.Value;
Word.InlineShape oShape;
object oClassType = "MSGraph.Chart.8";
Word.Range wrdRng = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing,
ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
//Demonstrate use of late bound oChart and oChartApp objects to
//manipulate the chart object with MSGraph.
object oChart;
object oChartApp;
oChart = oShape.OLEFormat.Object;
oChartApp = oChart.GetType().InvokeMember("Application",BindingFlags.GetProperty, null, oChart, null);
//Change the chart type to Line.
object[] Parameters = new Object[1];
Parameters[0] = 4; //xlLine = 4
oChart.GetType().InvokeMember("ChartType", BindingFlags.SetProperty,
null, oChart, Parameters);
Chart objChart = (Chart)oShape.OLEFormat.Object;
objChart.ChartType = XlChartType.xlColumnClustered;
//绑定数据
DataSheet dataSheet;
dataSheet = objChart.Application.DataSheet;
int rownum=data.GetLength(0);
int columnnum=data.GetLength(1);
for(int i=1;i<=rownum;i++ )
for (int j = 1; j <= columnnum; j++)
{
dataSheet.Cells[i,j] =data[i-1,j-1]; } objChart.Application.Update();
oChartApp.GetType().InvokeMember("Update",
BindingFlags.InvokeMethod, null, oChartApp, null);
oChartApp.GetType().InvokeMember("Quit",
BindingFlags.InvokeMethod, null, oChartApp, null);
//设置大小
oShape.Width = WordApp.InchesToPoints(6.25f);
oShape.Height = WordApp.InchesToPoints(3.57f);
}
}
}

 

测试程序

 

private   void  button3_Click( object  sender, EventArgs e)
{ object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc" ; /* \endofdoc is a predefined bookmark */ //Start Word and create a new document.
Word.Application oWord;
Word.Document oDoc;
oWord = new Word.Application();
oWord.Visible = true ;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing); ////添加页眉
String HeaderText = "石化盈科" ;
// AddHeader.AddSimpleHeader(oWord, HeaderText);
WdParagraphAlignment wdAlign = WdParagraphAlignment.wdAlignParagraphCenter;
WdColor fontcolor = WdColor.wdColorBlue;
float fontsize = 10;
//AddHeader.AddSimpleHeader(oWord, HeaderText, wdAlign);
AddHeader.AddSimpleHeader(oWord, HeaderText, wdAlign,fontcolor,fontsize); //Insert a paragraph at the beginning of the document.
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "Heading 1" ;
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter(); //Insert a paragraph at the end of the document.
Word.Paragraph oPara2;
object oRng = oDoc.Bookmarks.get_Item( ref oEndOfDoc).Range;
oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara2.Range.Text = "Heading 2" ;
oPara2.Format.SpaceAfter = 6;
oPara2.Range.InsertParagraphAfter(); //插入文字
Word.Paragraph oPara3;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara3.Range.Text = "This is a sentence of normal text. Now here is a table:" ;
oPara3.Range.Font.Bold = 0;
oPara3.Format.SpaceAfter = 24;
oPara3.Range.InsertParagraphAfter(); string text = "zhangruichao " ;
WdColor textcolor = fontcolor;
float textsize = 12;
AddLine.AddSimpLine(oDoc, oEndOfDoc, oRng, text, textcolor, textsize); //插入表格
WdLineStyle OutStyle = WdLineStyle.wdLineStyleThickThinLargeGap;
WdLineStyle InStyle = WdLineStyle.wdLineStyleSingle;
AddTable.AddSimpleTable(oWord, oDoc, 12, 3, OutStyle, InStyle); //插入分页
Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
object oPageBreak = Word.WdBreakType.wdPageBreak;
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertBreak(ref oPageBreak);
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertAfter("We're now on page 2. Here's my chart:" );
wrdRng.InsertParagraphAfter(); //Insert a chart.
string [,] data= new string [4,5]; data[0,1] = "第一月" ;
data[0, 2] = "第二月" ;
data[0, 3] = "第三月" ;
data[0, 4] = "第四月" ; data[1,0] = "东部" ;
data[1,1] = "50" ;
data[1,2] = "50" ;
data[1,3] = "40" ;
data[1,4] = "50" ; data[2,0] = "西部" ;
data[2,1] = "60" ;
data[2,2] = "60" ;
data[2,3] = "70" ;
data[2,4] = "80" ; //data[3,6] = "0";
data[3,0] = "中部" ;
data[3,1] = "50" ;
data[3,2] = "50" ;
data[3,3] = "40" ;
data[3,4] = "50" ; AddChart.AddSimpleChart(oDoc, oWord, oEndOfDoc, data); wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
wrdRng.InsertParagraphAfter();
wrdRng.InsertAfter("THE END." ); //Close this form.
this .Close(); }

Microsoft.Office.Interop.Word 创建word的更多相关文章

  1. 关于.net Microsoft.Office.Interop.Word组建操作word的问题,如何控制word表格单元格内部段落的样式。

    控制word表格单元格内部文字样式.我要将数据导出到word当中,对于word表格一个单元格中的一段文字,要设置不同的样式,比如第一行文字作为标题要居中,加粗,第二行为正常的正文. 代码如下 publ ...

  2. 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。

    无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Wor ...

  3. (转)无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。此操作失败的原因是对 IID 为“{00020970-

    HRESULT:0x80030002 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft ...

  4. VS编程中找不到Microsoft.Office.Core、Microsoft.Office.Interop.Word和VBIDE

    在使用vs2005. vs2008. vs2010 制作包含 word等office的应用程序时,有时找不到对Microsoft.Office.Core. Microsoft.Office.Inter ...

  5. C#引用Office.word出错的解决办法-无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass” 【转】

    本文章转自 suchso 1.系统找不到 Microsoft.Office.Interop.Word" "Could not load file or assembly 'Micr ...

  6. 无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass”。请改用适用的接口。

    引用里找到Microsoft.Office.Interop.Word右键属性 在嵌入互操作类型里,选上False就行了.

  7. System.InvalidCastException: 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。

    报错:System.InvalidCastException: 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接 ...

  8. 用 DocumentFormat.OpenXml 和Microsoft.Office.Interop.Word 写入或者读取word文件

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...

  9. 错误类型“Microsoft.Office.Interop.Word.ApplicationClass”未定义构造函数

    原文网址:http://zhidao.baidu.com/link?url=WcvaYFI1JeEGvbjD77nDbGp21sjaNCnCTRLGrU5YjwUGbHbhHJxQolKbsMZbZs ...

随机推荐

  1. Python2 基本数据结构源码解析

    Python2 基本数据结构源码解析 Contents 0x00. Preface 0x01. PyObject 0x01. PyIntObject 0x02. PyFloatObject 0x04. ...

  2. Python之路【第三篇】python基础 之基本数据类型 补充

    字符串格式化 Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-310 ...

  3. finally回收资源

    Java中的垃圾回收机制,也就是GC不会回收任何物理资源,垃圾回收机制只回收堆内存中对象所占用的内存,所以其他的物理资源需要用finally来回收. 如果try块中的某条语句引起了异常,该异常就会被c ...

  4. 实例讲解 SQL 注入攻击

    这是一篇讲解SQL注入的实例文章,一步一步跟着作者脚步探索如何注入成功,展现了一次完整的渗透流程,值得一读.翻译水平有限,见谅! 一位客户让我们针对只有他们企业员工和顾客能使用的企业内网进行渗透测试. ...

  5. java的英文词频算法

    java实现的英文词频算法,通常是采用单词树来实现的.使用java实现词频统计,为了统计词汇出现频率,最简单的做法是再建立一个map,其中,key是单词,value代表次数.将文章从头读到尾,读到一个 ...

  6. Android四大组件--事务详解(转)

    一.什么是事务 事务是访问数据库的一个操作序列,数据库应用系统通过事务集来完成对数据库的存取.事务的正确执行使得数据库从一种状态转换成另一种状态.   事务必须服从ISO/IEC所制定的ACID原则. ...

  7. 非域环境下搭建自动故障转移镜像无法将 ALTER DATABASE 命令发送到远程服务器实例的解决办法

    非域环境下搭建自动故障转移镜像无法将 ALTER DATABASE 命令发送到远程服务器实例的解决办法 环境:非域环境 因为是自动故障转移,需要加入见证,事务安全模式是,强安全FULL模式 做到最后一 ...

  8. MySQL 主主复制

    200 ? "200px" : this.width)!important;} --> 介绍 环境 OS:CentOS 6.7,MySQL 5.6 Master:192.16 ...

  9. C# 6.0 功能预览 (二)

    在Language Feature Status上面看到,其实更新的并不是特别多,为了不会误导看了C# 6.0 功能预览 (一)的园友,现在把官方的更新列表拿了过来,供大家参考 Roslyn 编译平台 ...

  10. lua中实现异步资源读写

    同样还是更新方面的需求,当我们检测到版本是新安装的以后,要进行upd目录清除.如果使用os.execute执行 rm -rf ooxx 是非常快的但由于os.execute一旦报错,那整个lua进程就 ...