91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 46KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-18
  • 語言: C#
  • 標(biāo)簽: C#??生成Word??保存Word??

資源簡介

動態(tài)生成Word,此示例程序中的Word含有文字、圖片、表格、圖標(biāo)、格式等元素。 生成完之后打印預(yù)覽、保存到C盤根目錄,最后退出。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?Word?=?Microsoft.Office.Interop.Word;
using?System.Reflection;


namespace?WordDemo
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{

????????}
????????///?
????????///?聲明:此方法Copy自互聯(lián)網(wǎng),代碼注釋原本為English
????????///?由“奔放的胸毛。(luoyuan@ly-zane.com)”笨拙翻譯,湊合著看吧
????????///?項目引用了Office自帶的COM組件Microsoft?Word
????????///?

????????///?
????????///?
????????private?void?button1_Click(object?sender?System.EventArgs?e)
????????{
????????????object?oMissing?=?Missing.Value;
????????????object?oEndOfDoc?=?“\\endofdoc“;?//指定編碼

????????????//開始
????????????Word._Application?oWord;//聲明一個Word應(yīng)用程序
????????????Word._Document?oDoc;//聲明一個Word文檔
????????????oWord?=?new?Word.Application();//實例化
????????????oWord.Visible?=?true;//顯示此文檔
????????????oDoc?=?oWord.Documents.Add(ref?oMissing?ref?oMissing
????????????????ref?oMissing?ref?oMissing);


????????????//添加頁眉
????????????oWord.ActiveWindow.View.Type?=?Word.WdViewType.wdOutlineView;
????????????oWord.ActiveWindow.View.SeekView?=?Word.WdSeekView.wdSeekPrimaryHeader;
????????????oWord.ActiveWindow.ActivePane.Selection.InsertAfter(“[頁眉內(nèi)容]“);
????????????oWord.Selection.ParagraphFormat.Alignment?=?Word.WdParagraphAlignment.wdAlignParagraphRight;//設(shè)置右對齊
????????????oWord.ActiveWindow.View.SeekView?=?Word.WdSeekView.wdSeekMainDocument;//跳出頁眉設(shè)置

????????????oWord.Selection.ParagraphFormat.LineSpacing?=?15f;//設(shè)置文檔的行間距



????????????//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;//加粗1
????????????oPara1.Format.SpaceAfter?=?24;??????//24?pt?spacing?after?paragraph.(在此段落之后添加24磅的行距)
????????????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);//將oRng這個行添加到文檔中并返回
????????????oPara2.Range.Text?=?“Heading?2“;//在此段落的行中添加字符串
????????????oPara2.Format.SpaceAfter?=?6;//在此段落之后添加6磅的行距
????????????oPara2.Range.InsertParagraphAfter();

????????????//Insert?another?paragraph.
????????????//添加作者段落
????????????Word.Paragraph?oPara3;
????????????oRng?=?oDoc.Bookmarks.get_Item(ref?oEndOfDoc).Range;
????????????oPara3?=?oDoc.Content.Paragraphs.Add(ref?oRng);
????????????oPara3.Range.Text?=?“This?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????913??2010-08-09?16:32??WordDemo.sln

????..A..H.?????14336??2010-08-10?13:04??WordDemo.suo

?????文件???????4139??2010-08-09?16:38??WordDemo\WordDemo.csproj

?????文件????????467??2010-08-09?16:32??WordDemo\Program.cs

?????文件???????2091??2010-08-09?16:38??WordDemo\Form1.Designer.cs

?????文件???????5814??2010-08-09?16:38??WordDemo\Form1.resx

?????文件???????1970??2010-08-10?13:01??WordDemo\obj\WordDemo.csproj.FileListAbsolute.txt

?????文件????????680??2010-08-10?10:18??WordDemo\obj\Debug\WordDemo.csproj.ResolveComReference.cache

?????文件????????180??2010-08-10?10:18??WordDemo\obj\Debug\WordDemo.Form1.resources

?????文件????????180??2010-08-10?10:18??WordDemo\obj\Debug\WordDemo.Properties.Resources.resources

?????文件????????842??2010-08-10?10:18??WordDemo\obj\Debug\WordDemo.csproj.GenerateResource.Cache

?????文件??????26112??2010-08-10?13:01??WordDemo\obj\Debug\WordDemo.pdb

?????文件??????24576??2010-08-10?13:01??WordDemo\obj\Debug\WordDemo.exe

?????文件???????5632??2005-11-11?22:25??WordDemo\bin\Debug\WordDemo.vshost.exe

?????文件???????4814??2010-08-09?10:46??WordDemo\bin\Debug\tempcode.bmp

?????文件??????24576??2010-08-10?13:01??WordDemo\bin\Debug\WordDemo.exe

?????文件??????26112??2010-08-10?13:01??WordDemo\bin\Debug\WordDemo.pdb

?????文件??????32768??2010-08-10?13:01??WordDemo\bin\Debug\zane.doc

?????文件???????5612??2010-08-09?16:32??WordDemo\Properties\Resources.resx

?????文件????????249??2010-08-09?16:32??WordDemo\Properties\Settings.settings

?????文件???????1200??2010-08-09?16:32??WordDemo\Properties\AssemblyInfo.cs

?????文件???????2872??2010-08-09?16:32??WordDemo\Properties\Resources.Designer.cs

?????文件???????1093??2010-08-09?16:32??WordDemo\Properties\Settings.Designer.cs

?????文件??????11575??2010-08-10?13:04??WordDemo\Form1.cs

?????目錄??????????0??2010-08-09?23:03??WordDemo\obj\Debug\TempPE

?????目錄??????????0??2010-08-09?23:03??WordDemo\obj\Debug

?????目錄??????????0??2010-08-09?23:03??WordDemo\bin\Debug

?????目錄??????????0??2010-08-09?23:03??WordDemo\obj

?????目錄??????????0??2010-08-09?23:03??WordDemo\bin

?????目錄??????????0??2010-08-09?23:03??WordDemo\Properties

............此處省略4個文件信息

評論

共有 條評論