前言

1、写这个功能之前,我得说说微软的这个类库,用着真苦逼!是他让我有程序猿,攻城尸的感觉了。首先这个类库,从没接触过,方法与属性都不懂,还没有提示。神啊,我做这功能真是一步一卡,很潇洒啊。

2、这个功能做下来了,不过通过苦逼的摸索我找到了一个捷径,就是 word 自带的 宏 ,感谢 word , 感谢宏 , 是它让我看到了,成功的可能性。

3、
说说宏,对于word来说,宏就是建立word文档的命令集,不过对于c#程序员来说,宏使用的是神器 vb
编写的。看到这里不懂神器的你,是不是顿悟了想死的心。呵呵,不用,因为,通过看宏的编码,我们可以感受到c#的影子,有些属性名字,很庆幸,在c#中是
不变的。

看看宏代码

使用宏,是录制宏,然后查看宏,就行了,下面我展示一个建立表格的宏命令

Sub 宏3()
'
' 宏3 宏
'
'
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:= _
7, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "网格型" Then
.Style = "网格型"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False //上面代码是在word中简历一个 8行 7列的表格
End With
Selection.MoveDown Unit:=wdLine, Count:=8 //向下移动八个光标,跳出表格
Selection.TypeParagraph //等于点回车键
Selection.TypeText Text:="上面有段向下移动光标的代码,因为不移动光标,怎么会有这一行字呢"
End Sub

上面这段代码,现在也许看着对我们的帮助不大,但是,一旦我们通过c#简历word 文档的时候,我们无从下手, 不知属性 ,方法的时候,就可以参照上面的代码,来写我们自己的代码了。

看看c#代码

这个功能真的没什么好说的,看代码说事吧。

引用 com ---》  Microsoft.Office.Interop.Word

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using Microsoft.Office.Interop.Word;
using com.enkj.job.WebUI.App_Code;
using System.Data;
using System.Reflection;
using JobCommon;

namespace com.enkj.job.WebUI.HttpHandler
{
    /// <summary>
    /// LoadWordResume 的摘要说明
    /// </summary>
    public class LoadWordResume :  PersonUserBase,IHttpHandler
    {
        public DataSet ds = null;
        public List<Model.Person> perList = null;
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request["action"] != null && context.Request["action"].ToString() == "LoadResume")
            {
                GetDataSet();
                context.Response.Write(CreateWord());
                context.Response.End();
            }
        }

DataSet GetDataSet()
        {
            ds = new Module.PersonResume().GetResumeInfo(sessionID, ResumeId);
            if (ds != null)
            {
                return ds;
            }
            throw new NoNullAllowedException();
        }

public string CreateWord()
        {
            string message = "";
            try
            {
                Object Nothing = System.Reflection.Missing.Value;
                Directory.CreateDirectory("D:/JobResume");  //创建文件所在目录
                
                string name = "JobResume_" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + ".doc";//文件名
                object filename = "D://JobResume//" + name;  //文件保存路径
                //创建Word文档
                Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
                Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
                WordApp.Selection.PageSetup.LeftMargin = 85f;
                WordApp.Selection.PageSetup.RightMargin = 85f;
                WordApp.Selection.PageSetup.PageWidth = 650f;  //页面宽度
                //添加页眉
                WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
                WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("蓝领招聘网模板生成");
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;//设置右对齐
                WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;//跳出页眉设置
                WordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距     
                //移动焦点并换行
                object count = 14;
                object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
                WordApp.Selection.Text = "个人简历";
                WordApp.Selection.ParagraphFormat.LineSpacing = 30f;
                WordApp.Selection.Range.Bold = 2;
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                WordApp.Selection.MoveDown(ref WdLine, ref count, ref Nothing);//移动焦点
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                WordApp.Selection.TypeParagraph();//插入段落
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                WordApp.Selection.ParagraphFormat.LineSpacing = 16;
                WordApp.Selection.Font.Size = 10f;
                WordApp.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray40;
                //文档中创建表格
                Microsoft.Office.Interop.Word.Table newTable = WordDoc.Tables.Add(WordApp.Selection.Range,8, 3, ref Nothing, ref Nothing);
                //设置表格样式
                newTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;                
                newTable.Columns[1].Width = 175f;
                newTable.Columns[2].Width = 170f;
                newTable.Columns[3].Width = 135f;
                //填充表格内容
                newTable.Cell(1, 1).Range.Text = "个人信息";
                newTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                newTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;              
                //合并单元格
                newTable.Cell(1, 1).Merge(newTable.Cell(1, 3));
                WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                newTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;
                //填充表格内容
                newTable.Cell(2, 1).Range.Text = "姓名:"+ds.Tables[0].Rows[0]["name"];
                newTable.Cell(2, 2).Range.Text = "性别:" + Common.DoEnum.EnumManager<JobCommon.ApplicationEnum.Sex>.GetEnumDesc(JobTool.Toint(ds.Tables[0].Rows[0]["sex"]));
                //纵向合并单元格
                newTable.Cell(2, 3).Select();//选中一行
                object moveUnit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
                object moveCount = 5;
                object moveExtend = Microsoft.Office.Interop.Word.WdMovementType.wdExtend;
                WordApp.Selection.MoveDown(ref moveUnit, ref moveCount, ref moveExtend);
                WordApp.Selection.Cells.Merge();             
                //插入图片
                string FileName = Server.MapPath(ds.Tables[0].Rows[0]["Photo"]!=null&&ds.Tables[0].Rows[0]["Photo"].ToString().Length>0?ds.Tables[0].Rows[0]["Photo"].ToString():"/sys_admin/images/noImg.jpg");//图片所在路径
                object LinkToFile = false;
                object SaveWithDocument = true;
                object Anchor = WordDoc.Application.Selection.Range;
                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
                WordDoc.Application.ActiveDocument.InlineShapes[1].Width = 80f;//图片宽度
                WordDoc.Application.ActiveDocument.InlineShapes[1].Height = 100f;//图片高
                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //将图片设置为四周环绕型
                Microsoft.Office.Interop.Word.Shape s = WordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape();
                s.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapSquare;

newTable.Cell(3, 1).Range.Text = "出生日期: "+Convert.ToDateTime(ds.Tables[0].Rows[0]["birthday"]).ToString("yyyy年MM月dd日");
                newTable.Cell(3, 2).Range.Text = "居住地 :" + GetCity();
                newTable.Cell(4, 1).Range.Text = "工作年限: " + GetWorkYears();
                newTable.Cell(5, 1).Range.Text = ds.Tables[0].Rows[0]["MobileNumber"] == null ? "手机号码: "+ds.Tables[0].Rows[0]["MobileNumber"] :  "联系电话: "+ds.Tables[0].Rows[0]["PhoneNumber"];
                newTable.Cell(6, 1).Range.Text = "邮编:" + ds.Tables[0].Rows[0]["PostCode"] == null ? "稍后填写" : ds.Tables[0].Rows[0]["PostCode"].ToString();
                newTable.Cell(6, 1).Range.Text = "身高:" + ds.Tables[0].Rows[0]["Height"] +" cm";
                newTable.Cell(7, 1).Range.Text = "户口 :" + GetHomeCity();
                newTable.Cell(8, 1).Range.Text = "QQ :" + (ds.Tables[0].Rows[0]["QQ"] == null ? "稍后填写" : ds.Tables[0].Rows[0]["QQ"].ToString());
                newTable.Cell(8,1).Range.Text = "电子邮箱:" + (ds.Tables[0].Rows[0]["Email"] == null ? "稍后填写" : ds.Tables[0].Rows[0]["Email"].ToString());

//求职意向          
                object missing = System.Reflection.Missing.Value;
                object count2 = 2;
                object WdLine2 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;  
                WordApp.Selection.MoveDown(ref WdLine2, ref count2, ref missing);//光标向下移1行  
                WordApp.Selection.TypeParagraph();//在表格外回车

if (ds.Tables[1].Rows.Count > 0)
                {

//文档中创建表格
                    Microsoft.Office.Interop.Word.Table QzyxTable = WordDoc.Tables.Add(WordApp.Selection.Range, 6, 1, ref Nothing, ref Nothing);
                    //设置表格样式
                    QzyxTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                    QzyxTable.Columns[1].Width = 480f;
                    //填充表格内容
                    QzyxTable.Cell(1, 1).Range.Text = "求职意向";
                    QzyxTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                    QzyxTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
                    //合并单元格
                    WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                    WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                    QzyxTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;
                    QzyxTable.Cell(2, 1).Range.Text = "工作性质: " + GetJobType();
                    QzyxTable.Cell(3, 1).Range.Text = "期望月薪: " + GetMouthSalary();
                    QzyxTable.Cell(4, 1).Range.Text = "工作地点: " + ds.Tables[1].Rows[0]["Workplace"];
                    QzyxTable.Cell(5, 1).Range.Text = "到岗时间: " + ds.Tables[1].Rows[0]["WorkTime"];
                    QzyxTable.Cell(6, 1).Range.Text = "自我评价: " + ds.Tables[1].Rows[0]["MyEvaluate"];
                }

//工作经验
                object count3 = 6;
                WordApp.Selection.MoveDown(ref WdLine2, ref count3, ref missing);//光标向下移1行  
                WordApp.Selection.TypeParagraph();//在表格外回车
                int j = 2;
                if (ds.Tables[3].Rows.Count > 0)
                {
                    //工作经验个数
                    int i = ds.Tables[3].Rows.Count;
                    //文档中创建表格
                    Microsoft.Office.Interop.Word.Table GzjyTable = WordDoc.Tables.Add(WordApp.Selection.Range, i*5, 1, ref Nothing, ref Nothing);
                    //设置表格样式
                    GzjyTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                    GzjyTable.Columns[1].Width = 480f;
                    //填充表格内容
                    GzjyTable.Cell(1, 1).Range.Text = "工作经验";
                    GzjyTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                    GzjyTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
                    //合并单元格
                    WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                    WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                    GzjyTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;                   
                    
                    for (int k = 0; k < i; k++)
                    {

GzjyTable.Cell(j, 1).Range.Text = JobTool.ToDateTimeNow(ds.Tables[3].Rows[k]["BeginTime"]).ToString("yyyy-MM") + "--" + JobTool.ToDateTimeNow(ds.Tables[3].Rows[k]["EndTime"]).ToString("yyyy-MM") + ":" + " " + ds.Tables[3].Rows[k]["WorkCompany"] + "(" + GetComRange(ds.Tables[3].Rows[k]["Scale"]) + ")" + " [ " + GetInWorkYears(ds.Tables[3].Rows[k]["BeginTime"], ds.Tables[3].Rows[k]["EndTime"]) + "]";

GzjyTable.Cell(j + 1, 1).Range.Text = "所属行业:        " + GetIndustryType(ds.Tables[3].Rows[k]["Industry"]);
                        GzjyTable.Cell(j + 2, 1).Range.Text = ds.Tables[3].Rows[k]["Department"] + "              " + ds.Tables[3].Rows[k]["Post"];
                        GzjyTable.Cell(j + 3, 1).Range.Text = "" + ds.Tables[3].Rows[k]["WorkDescription"];
                        if (i * 5 + 1 != j + 4)
                        {
                            GzjyTable.Cell(j + 4, 1).Range.InlineShapes.AddHorizontalLineStandard(ref Nothing);
                        }
                        j = j + 5;
                    }
                }

//教育经历
                object count4 = j;
                WordApp.Selection.MoveDown(ref WdLine2, ref count4, ref missing);//光标向下移1行  
                WordApp.Selection.TypeParagraph();//在表格外回车
                if (ds.Tables[2].Rows.Count > 0)
                {
                    //教育经历个数
                    int i = ds.Tables[2].Rows.Count;
                    //文档中创建表格
                    Microsoft.Office.Interop.Word.Table jyjlTable = WordDoc.Tables.Add(WordApp.Selection.Range, i * 4, 1, ref Nothing, ref Nothing);
                    //设置表格样式
                    jyjlTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                    jyjlTable.Columns[1].Width = 480f;
                    //填充表格内容
                    jyjlTable.Cell(1, 1).Range.Text = "教育经历";
                    jyjlTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                    jyjlTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
                    //合并单元格
                    WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                    WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                    jyjlTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;
                    j = 2;
                    for (int k = 0; k < i; k++)
                    {
                        jyjlTable.Cell(j, 1).Range.Text = JobTool.ToDateTimeNow(ds.Tables[2].Rows[k]["BeginTime"]).ToString("yyyy-MM") + "--" + JobTool.ToDateTimeNow(ds.Tables[2].Rows[k]["EndTime"]).ToString("yyyy-MM") + ":" + " " + ds.Tables[2].Rows[k]["school"] + "         (" + ds.Tables[2].Rows[k]["EduBackground"] + ")" ;
                        jyjlTable.Cell(j + 1, 1).Range.Text = "专业:        " + ds.Tables[2].Rows[k]["Specialty"];
                        jyjlTable.Cell(j + 2, 1).Range.Text = ""+ds.Tables[2].Rows[k]["SpecialtyDescription"];
                        if (i * 4 + 1 != j + 3)
                        {
                            jyjlTable.Cell(j + 3, 1).Range.InlineShapes.AddHorizontalLineStandard(ref Nothing);
                        }
                        j = j + 4;
                    }
                }

//培训经历
                object count5 = j+8;
                WordApp.Selection.MoveDown(ref WdLine2, ref count5, ref missing);//光标向下移1行  
                WordApp.Selection.TypeParagraph();//在表格外回车
                if (ds.Tables[4].Rows.Count > 0)
                {
                    //培训经历个数
                    int i = ds.Tables[4].Rows.Count;
                    //文档中创建表格
                    Microsoft.Office.Interop.Word.Table pxjlTable = WordDoc.Tables.Add(WordApp.Selection.Range, i * 5, 1, ref Nothing, ref Nothing);
                    //设置表格样式
                    pxjlTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                    pxjlTable.Columns[1].Width = 480f;
                    //填充表格内容
                    pxjlTable.Cell(1, 1).Range.Text = "培训经历";
                    pxjlTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                    pxjlTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
                    //合并单元格
                    WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                    WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                    pxjlTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;
                    j = 2;
                    for (int k = 0; k < i; k++)
                    {
                        pxjlTable.Cell(j, 1).Range.Text = "时  间:    " + JobTool.ToDateTimeNow(ds.Tables[4].Rows[k]["BeginTime"]).ToString("yyyy-MM") + "--" + JobTool.ToDateTimeNow(ds.Tables[4].Rows[k]["EndTime"]).ToString("yyyy-MM") + "" + "           培训机构:  " + ds.Tables[4].Rows[k]["CultivateCompany"] ;
                        pxjlTable.Cell(j + 1, 1).Range.Text = "培训地点:        " + ds.Tables[4].Rows[k]["Address"] + "                 培训课程:  " + ds.Tables[4].Rows[k]["Subject"];
                        pxjlTable.Cell(j + 2, 1).Range.Text = "获得证书:" + ds.Tables[4].Rows[k]["Certificate"];
                        pxjlTable.Cell(j + 3, 1).Range.Text = "自我评价:" + ds.Tables[4].Rows[k]["Description"];
                        if (i * 5 + 1 != j + 4)
                        {
                            pxjlTable.Cell(j + 4, 1).Range.InlineShapes.AddHorizontalLineStandard(ref Nothing);
                        }
                        j = j + 5;
                    }
                }
                //语言能力
                object count6 = j + 3;
                WordApp.Selection.MoveDown(ref WdLine2, ref count6, ref missing);//光标向下移1行  
                WordApp.Selection.TypeParagraph();//在表格外回车
                if (ds.Tables[5].Rows.Count > 0)
                {
                    //语言能力个数
                    int i = ds.Tables[5].Rows.Count;
                    //文档中创建表格
                    Microsoft.Office.Interop.Word.Table yynlTable = WordDoc.Tables.Add(WordApp.Selection.Range, i * 5, 1, ref Nothing, ref Nothing);
                    //设置表格样式
                    yynlTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
                    yynlTable.Columns[1].Width = 480f;
                    //填充表格内容
                    yynlTable.Cell(1, 1).Range.Text = "语言能力";
                    yynlTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体
                    yynlTable.Cell(1, 1).Range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
                    //合并单元格
                    WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom;//垂直居下
                    WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;//水平居左
                    WordApp.Selection.Shading.BackgroundPatternColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
                    yynlTable.Rows[1].Range.ParagraphFormat.LineSpacing = 20f;
                    j = 2;
                    for (int k = 0; k < i; k++)
                    {
                        yynlTable.Cell(j, 1).Range.Text = "语言类别: " + ds.Tables[5].Rows[k]["language"];
                        yynlTable.Cell(j + 1, 1).Range.Text = "掌握程度:" + ds.Tables[5].Rows[k]["level"];
                        yynlTable.Cell(j + 2, 1).Range.Text = "读写能力:" + ds.Tables[5].Rows[k]["ReadWrite"];
                        yynlTable.Cell(j + 3, 1).Range.Text = "听说能力:" + ds.Tables[5].Rows[k]["ListenSpeak"];
                        if (i * 5 + 1 != j + 4)
                        {
                            yynlTable.Cell(j + 4, 1).Range.InlineShapes.AddHorizontalLineStandard(ref Nothing);
                        }
                        j = j + 5;
                    }
                }
                //文件保存
                WordDoc.SaveAs(ref filename, 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);
                WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
                WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
                message = name + "文档生成成功,以保存到 D:\\JobResume 下";
            }
            catch
            {
                message = "文件导出异常!";
            }
            return message;
        }

public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

再看看效果吧,也算是我秀一下

转载原文:http://www.cnblogs.com/knowledgesea/archive/2013/05/24/3095376.html

c#操作word文档之简历导出的更多相关文章

  1. iText操作word文档总结

    操作word文档的工具有很多,除了iText之外还有POI,但是POI擅长的功能是操作excel,虽然也可以操作word,但是能力有限,而且还有很多的bug,技术并不成熟,下面就重点介绍一种操作wor ...

  2. C#操作Word文档(加密、解密、对应书签插入分页符)

    原文:C#操作Word文档(加密.解密.对应书签插入分页符) 最近做一个项目,客户要求对已经生成好的RTF文件中的内容进行分页显示,由于之前对这方面没有什么了解,后来在网上也找了相关的资料,并结合自己 ...

  3. 利用Python操作Word文档【图片】

    利用Python操作Word文档

  4. Java文件操作系列[3]——使用jacob操作word文档

    Java对word文档的操作需要通过第三方组件实现,例如jacob.iText.POI和java2word等.jacob组件的功能最强大,可以操作word,Excel等格式的文件.该组件调用的的是操作 ...

  5. C# 导出word文档及批量导出word文档(4)

          接下来是批量导出word文档和批量打印word文件,批量导出word文档和批量打印word文件的思路差不多,只是批量打印不用打包压缩文件,而是把所有文件合成一个word,然后通过js来调用 ...

  6. 2.QT中操作word文档

     Qt/Windows桌面版提供了ActiveQt框架,用以为Qt和ActiveX提供完美结合.ActiveQt由两个模块组成: A   QAxContainer模块允许我们使用COM对象并且可以 ...

  7. 【Java】导出word文档之freemarker导出

    Java导出word文档有很多种方式,本例介绍freemarker导出,根据现有的word模板进行导出 一.简单导出(不含循环导出) 1.新建一个word文件.如下图: 2.使用word将文件另存为x ...

  8. Asp.net操作Word文档,原来这么简单啊!

    引用Word对象库文件  具体做法是打开菜单栏中的项目>添加引用>浏览,在打开的“选择组件”对话框中找到MSWORD.OLB后按确定即可引入此对象库文件,vs.net将会自动将库文件转化为 ...

  9. QTP操作word文档

    QTP可以对word文档进行操作,这里最主要展示的是向word文档写入内容,并保存的功能. Option explicit Dim wordApp Set wordApp = createobject ...

随机推荐

  1. java 数字前自动补零实现

    /** * 里数字转字符串前面自动补0的实现. * */ public class TestStringFormat { public static void main(String[] args) ...

  2. 初识Java--线程同步(2)

    本文讲述Java中的线程同步和生产者消费者问题,其中主要涉及线程同步和wait().notify()方法的用法. wait和notify方法只能用在线程同步中,wait和notify是object的方 ...

  3. AutoResetEvent和ManualResetEvent

    本文在于巩固基础 AutoResetEvent 概念:通知正在等待的线程已发生的事件 如果AutoResetEvent 为非终止状态,则线程会被阻止,并等待当前控制资源的线程通过调用 Set 来通知资 ...

  4. iOS 任意类型数据转换字符串

    //转换数据类型: NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:resp ...

  5. jquery解决onmouseover和onmouseout合用的bug问题

    经常会遇到鼠标放到一个元素上显示另外一个元素,这两个元素是父子关系,比如在A上绑定mouseover和mouseout事件来显示或隐藏B元素,A元素包含B元素,当鼠标移到B元素后浏览器认为你移开了A, ...

  6. day10_python学习笔记_chapter13_面向对象编程

    1. class NewClass(parent): def .... 如果没有父类, 则默认继承object类 2. 类属性访问(类似java中的静态属性和方法)直接用类名.属性名, 在python ...

  7. sersync+inotify实时备份数据

    Sersync项目简介与框架 简介 Sersync项目利用inotify与rsync技术实现对服务器数据实时同步的解决方案,其中inotify用于监控sersync所在服务器上文件系统的事件变化,rs ...

  8. 解决ie6支持最大高度最小高度的方法

    1.IE6支持max-height解决方法 IE6支持最大高度解决CSS代码:.yangshi{max-height:1000px;_height:expression((document.docum ...

  9. JavaScript中创建命名空间

    引用:http://ourjs.com/detail/538d8d024929582e6200000c   在JavaScript中全局变量经常会引起命名冲突,甚至有时侯重写变量也不是按照你想像中的顺 ...

  10. c 函数传入数组。

    php 里面 直接 count($arr); 一个函数搞定, c里面想判断下数组的个数却非常困难. 想到php是C写的,那看看他的函数怎么写的不就行了... 哦,天啊,,事实比我想的要复杂的多... ...