Loading...

          java .net

          C# 在word文檔中復制表格并粘帖到下一頁中

          object oMissing = System.Reflection.Missing.Value;
                      Microsoft.Office.Interop.Word._Application oWord;
                      Microsoft.Office.Interop.Word._Document oDoc;
                      oWord = new Microsoft.Office.Interop.Word.Application();
                      //顯示word文檔
                      oWord.Visible = true;
                      //取得word文件模板
                      object fileName = System.Windows.Forms.Application.StartupPath + "\\word.doc";
                      //根據模板生成一個新文檔,相當于另存為
                      oDoc = oWord.Documents.Add(ref fileName, ref oMissing,
                                      ref oMissing, ref oMissing);

                      //復制第一個表格
                      oDoc.Tables[1].Select();
                      oWord.Selection.Copy();

                      //在這里操作表格中的文本
                      oDoc.Tables[1].Cell(1, 1).Range.Text = "這是第一個表格";

                      //下一頁
                      object mymissing = System.Reflection.Missing.Value;
                      object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
                      oWord.Selection.EndKey(ref myunit, ref mymissing);
                      object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
                      oWord.Selection.InsertBreak(ref pBreak);

                      //粘貼第一個表格
                      oWord.Selection.Paste();

                      oDoc.Tables[2].Cell(1, 1).Range.Text = "這是第二個表格";

          posted on 2008-08-26 22:06 閱讀(2798) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 临猗县| 淳化县| 临泉县| 甘洛县| 太康县| 秦皇岛市| 上饶市| 新疆| 于都县| 瑞安市| 江陵县| 英德市| 西乌| 本溪| 福海县| 开阳县| 花莲县| 高陵县| 定兴县| 大城县| 昭通市| 壤塘县| 太康县| 太仓市| 昌江| 龙岩市| 叶城县| 贵溪市| 砚山县| 鲁山县| 和静县| 六盘水市| 武宁县| 龙里县| 延长县| 伊宁市| 漠河县| 万年县| 崇义县| 余江县| 三明市|