标准js 能读的文件只有一种,那就是XML 读WORD只能用activex,例, var w=new ActiveXObject('Word.Application'); var docText; var obj; if (w != null) { w.Visible = true; obj=w.Documents.Open("C:\\A.doc"); docText = obj.Content; w.Selection.TypeText("Hello"); w.Documents.Save(); document.write(docText);//Print on webpage/*The Above Code Opens existing Document set w.Visible=false */ /*Below code will create doc file and add data to it and will close*/ w.Documents.Add(); w.Selection.TypeText("Writing This Message ...."); w.Documents.Save("c:\\doc_From_javaScript.doc"); w.Quit(); /*Don't forget set w.Visible=false */}
读WORD只能用activex,例,
var w=new ActiveXObject('Word.Application');
var docText;
var obj;
if (w != null)
{
w.Visible = true;
obj=w.Documents.Open("C:\\A.doc");
docText = obj.Content;
w.Selection.TypeText("Hello");
w.Documents.Save();
document.write(docText);//Print on webpage/*The Above Code Opens existing Document
set w.Visible=false
*/
/*Below code will create doc file and add data to it and will close*/
w.Documents.Add();
w.Selection.TypeText("Writing This Message ....");
w.Documents.Save("c:\\doc_From_javaScript.doc");
w.Quit();
/*Don't forget
set w.Visible=false */}