c#操作word文檔之簡歷導出


前言

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;
            }
        }
    }
}

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

 

 這功能,我也是摸索這前進的,就這樣子吧。。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM