发新话题
打印

如何将表单里的值传到word中

如何将表单里的值传到word中

我在表单中添加一个按钮,按钮的功能是打开固定格式的word,
创建word的js代码:
var myDocApp=null;
myDocApp =new ActiveXObject("word.Application");
myDocApp.Application.Visible = true;
var myDoc = myDocApp.Documents.Add();


myDocApp.Selection.ParagraphFormat.Alignment=1
myDocApp.Selection.Range.Bold=true;
myDocApp.Selection.Font.Size=22;
myDocApp.Selection.Text="请假申请单"
myDocApp.Selection.insertAfter("\n");
myDocApp.Selection.MoveRight(1,10);    
myDocApp.Selection.TypeParagraph();
myDocApp.Selection.Font.Bold=false;
myDocApp.Selection.Font.Size=12;



var myTable0=myDoc.Tables.Add(myDocApp.Selection.Range,3,4);

myTable0.cell(1,1).Range.Text="请假人"
myTable0.cell(1,2).Range.Text=""

myTable0.cell(1,3).Range.Text="请假时间"
myTable0.cell(1,4).Range.Text="2006-2-10"


myTable0.cell(2,1).Range.Text="工号"
myTable0.cell(2,2).Range.Text="32412"


myTable0.cell(2,3).Range.Text="填表时间"
myTable0.cell(2,4).Range.Text="2006-2-9"


myTable0.cell(3,1).Range.Text="请假原因"
myTable0.cell(3,2).Range.Text="感冒"


myTable0.cell(3,3).Range.Text="处理方式"
myTable0.cell(3,4).Range.Text="病假"

var range=myDocApp.ActiveDocument.Content;
range.Collapse(0);
range.insertAfter("\n");
range=myDocApp.ActiveDocument.Content;
range.Collapse(0);


var myTable1=myDoc.Tables.Add(range,2,1);

myTable1.cell(1,1).Range.Text="正文"
var wdRowHeightExactly
myTable1.Rows(2).SetHeight ( 200, wdRowHeightExactly )
myTable1.cell(2,1).Range.Text="天气突然降温,着凉引发感冒!!"



var range=myDocApp.ActiveDocument.Content;
range.Collapse(0);
range.insertAfter("\n");
range=myDocApp.ActiveDocument.Content;
range.Collapse(0);

var myTable2=myDoc.Tables.Add(range,1,2);

myTable2.Columns(1).SetWidth(320,2);
myTable2.cell(1,1).Range.Text=" 申请人签名" //空格勿删
// myTable2.cell(1,2).Range.Text="申请人的签名"
myTable2.cell(1,2).Select();
myDocApp.Selection.InlineShapes.AddPicture("E:\\user.gif");

var range=myDocApp.ActiveDocument.Content;
range.Collapse(0);
range.insertAfter("\n");
range=myDocApp.ActiveDocument.Content;
range.Collapse(0);


var myTable3=myDoc.Tables.Add(range,3,4);

myTable3.cell(1,1).Range.Text="组长意见"
myTable3.cell(1,2).Range.Text="同意"

myTable3.cell(1,3).Range.Text="签名"
myTable3.cell(1,4).Range.Text="组长的签名"


myTable3.cell(2,1).Range.Text="部门意见"
myTable3.cell(2,2).Range.Text="同意"


myTable3.cell(2,3).Range.Text="签名"
myTable3.cell(2,4).Range.Text="主任的签名"


myTable3.cell(3,1).Range.Text="厂领导意见"
myTable3.cell(3,2).Range.Text="同意"


myTable3.cell(3,3).Range.Text="签名"
myTable3.cell(3,4).Range.Text="厂领导签名"



try{
myDocApp.ActiveDocument.SaveAs("e:\\JaveToWord.doc");
}catch(exception){
alert("浏览器安全设置过高,保存文件到本地失败");
myDocApp.Documents.close();
myDocApp.Application.quit();
myDocApp=null;
window.close();
}
//myDocApp.Documents.close();
//myDocApp.Application.quit();
//myDocApp=null;
但是我如何在提交表单过程中把表单上的值传递到word的某一个区域中呢,谢谢!

TOP

发新话题
  清除 Cookies - 联系我们 - 邮件技术资讯网 - Archiver - WAP - 繁體中文
当前时区 GMT+8, 现在时间是 2008-11-23 05:23

本论坛为非盈利中立机构,论坛所有言论纯属发表者个人意见,与《 邮件技术资讯网》论坛立场无关。内容所涉及的版权和法律相关事宜请参考各自所有者的条款。
如果认定侵犯了您的权利,请联系我们尽快处理。本论坛原创内容请联系本站后再行转载并务必保留我站信息。此声明修改不再另行通知,本论坛保留最终解释权。
*本论坛QQ群:1#群2233231(已满) 2#群2598254(推荐) 3#群15974064(推荐) 4#群14173252(推荐)*
* 建议使用 1024×768 模式查看本论坛 *
Powered by Discuz! 6.1.0