在word文檔中創建表格的方法詳解
複製代碼 代碼如下:
public string CreateWordFile()
{
string message = "";
try
{
Object Nothing = e;
string name = "";
object filename = @"C:Usersxiehuanxxx" + name; //文件保存路徑
//創建Word文檔
ication WordApp = new icationClass();
ment WordDoc = (ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//添加頁眉
= tlineView;
View = ekPrimaryHeader;
rtAfter("[頁眉內容]");
nment = ignParagraphRight;//設置右對齊
View = ekMainDocument;//跳出頁眉設置
Spacing = 15f;//設置文檔的行間距
//移動焦點並換行
object count = 14;
object WdLine = ne;//換一行;
Down(ref WdLine, ref count, ref Nothing);//移動焦點
Paragraph();//插入段落
//文檔中創建表格
e newTable = (e, 12, 3, ref Nothing, ref Nothing);
//設置表格樣式
ideLineStyle = neStyleThickThinLargeGap;
deLineStyle = neStyleSingle;
mns[1]h = 100f;
mns[2]h = 220f;
mns[3]h = 105f;
//填充表格內容
(1, 1) = "產品詳細信息表";
(1, 1) = 2;//設置單元格中字體為粗體
//合併單元格
(1, 1)e((1, 3));
icalAlignment = llAlignVerticalCenter;//垂直居中
nment = ignParagraphCenter;//水平居中
//填充表格內容
(2, 1) = "產品基本信息";
(2, 1)r = lorDarkBlue;//設置單元格內字體顏色
//合併單元格
(2, 1)e((2, 3));
icalAlignment = llAlignVerticalCenter;
//填充表格內容
(3, 1) = "品牌名稱:";
(3, 2) = "BrandName";
//縱向合併單元格
(3, 3)ct();//選中一行
object moveUnit = ne;
object moveCount = 5;
object moveExtend = tend;
Down(ref moveUnit, ref moveCount, ref moveExtend);
e();
//插入圖片
string FileName = Picture;//圖片所在路徑
object LinkToFile = false;
object SaveWithDocument = true;
object Anchor = e;
icture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
neShapes[1]h = 100f;//圖片寬度
neShapes[1]ht = 100f;//圖片高度
//將圖片設置為四周環繞型
e s = neShapes[1]ertToShape();
= apSquare;
(12, 1) = "產品特殊屬性";
(12, 1)e((12, 3));
//在表格中增加行
es[1](ref Nothing);
= "文檔創建時間:" + ring();//“落款”
nment = ignParagraphRight;
//文件保存
As(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);
e(ref Nothing, ref Nothing, ref Nothing);
(ref Nothing, ref Nothing, ref Nothing);
message=name+"文檔生成成功,以保存到C:CNSI下";
}
catch (ption e)
{
(age);
}
return message;
}
-
Excel文檔無法另存怎麼辦
問:我用的是Windows98系統,前幾天當我打開一個Excel文件後,想把它另存為一個文件,系統提示説文件已存為某某臨時文件,請按“確定”,確定後,Excel就被關閉了,這是什麼原因?答:你可以刪除保存的臨時文件,然後再進行另存。首先到系統分區中的“Windowsemp”文件夾中刪除所有...
-
關於如何將Word2003的文檔打印成小冊子的教程
Word2003是微軟公司提供的一款文字處理軟件,可以對文字進行排版和編輯、分段等各種處理,最終將編輯好的內容打印出來,是辦公室一族中必備的辦公軟件之一。Word2003具有一個“書籍摺頁”的功能,能夠在一頁紙上打印兩頁的內容,打印後可以從中縫裝訂成摺疊的`小冊子,更...
-
在excel中對多個工作表快速編輯的方法
如果想一次操作多張相同的工作表,省略以後的複製、粘貼操作,可採用以下方法。按住Shift鍵或Ctrl鍵並配以鼠標操作,在工作簿底部選擇多個彼此相鄰或不相鄰的工作表標籤,就可以實行多方面的批量處理。一般情況下,進行的操作主要有如下幾種:1.頁面設置,可快速對選中工作...
-
excel基礎知識選擇題「附答案」
一、單選題1、在Excel2003中,若A1:A5命名為xi,數值分別為10、7、9、27和2,C1:C3命名為axi,數值為4、18和7,則AVERAGE(xi,axi)等於______。A:10.5B:22.5C:14.5D:42答案:A2、在Excel2003中,以下選項引用函數正確的是______。A:=(sum)A1:A5B:=sum(A2,B3,B7)C:=sumA1:A5D:=sum(A10...