如题
解决方案 »
- js拾色器遇到瓶颈了,求帮助!
- 请问dtree节点如何调用C#后台函数?
- 请教播音问题
- [馨郁星愿]javascript的历遍问题:
- 不用window.open()函数可以做一个无边框的窗口吗?
- javascript网页能不能 读取文本文件上的内容,把它们显示到 网页上去呢?
- 紧急求救:请问如何让鼠标停在网页上某处时出现一个提示信息框
- 关于界面自适应宽度的显示问题.
- 怎么把html语句用document.write()显示出来?需要把字符串的那些东西替换?
- jquery中的filter与contains有什么不同?
- jsp页面中我采用了框架,加上图片飘来飘去的效果后,页面内容成空白了
- javascript中如何定义相对路径?
早先用 js + access 做过些小东东,excel 应该差不多,
楼主自己动手搜搜吧!
var MyData= new GetTableData(Obj,0,0);
var myrows=MyData.rows;
var i,j; try {
var xls = new ActiveXObject ( "Excel.Application" );
}
catch(e) {
alert( "要打印该表,您必须安装Excel电子表格软件,同时浏览器须使用“ActiveX 控件”,您的浏览器须允许执行控件。 请点击【帮助】了解浏览器设置方法!");
return "";
}
if (typeof(ProceVisible)=="undefined"){
xls.visible = true;
}
else{
if (ProceVisible=="true"){
xls.visible = true;
}
else
{
xls.visible = false;
}
}
var xlBook = xls.Workbooks.Add;
var xlsheet = xlBook.Worksheets(1);
xls.Cells.Select;
xls.Selection.NumberFormatLocal = "@";
for (i=0;i<MyData.rows ;i++){
for (j=0;j<MyData.cols ;j++){
if (typeof(MyData.GetFieldData(j)) == "number"){
xlsheet.Cells(i+1,j+1).NumberFormatLocal = "0.00_ ";
}
xlsheet.Cells(i+1,j+1).Value= MyData.GetFieldData(j);
}
MyData.MoveNext();
}
if (SaveAsFilename=="" || typeof(SaveAsFilename)=="undefined"){
var fname = xls.Application.GetSaveAsFilename("*.xls", "Excel Spreadsheets (*.xls), *.xls");
if (fname!=""){
xlBook.SaveAs(fname);
}
}
else{
xlBook.SaveAs(SaveAsFilename);
}
xlBook.Close (savechanges=false);
//xls.visible = false;
xls.Quit();
xls=null;
//结束excel进程,退出完成
window.setInterval("Cleanup();",1);
}
<script>
function mytest1() {
var Excel, Book; // Declare the variables
Excel = new ActiveXObject("Excel.Application"); // Create the Excel application object.
Excel.Visible = false; // Make Excel invisible.
Book = Excel.Workbooks.Add() // Create a new work book.
Book.ActiveSheet.Cells(1,1).Value = document.all.my_textarea1.value;
Book.SaveAs("C:/Documents and Settings/ProGamer/Desktop/word to text/TEST.xls");
Excel.Quit(); // Close Excel with the Quit method on the Application object.
}function mytest2() {
var Excel;
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
form1.my_textarea2.value = Excel.Workbooks.Open("C:/Documents and Settings/ProGamer/Desktop/word to text/TEST.xls").ActiveSheet.Cells(1,1).Value;
Excel.Quit();
}</script><body>
<form name="form1">
<input type=button onClick="mytest1();" value="Send Excel Data"><input type=text name="my_textarea1" size=70 value="enter ur data here">
<br><br>
<input type=button onClick="mytest2();" value="Get Excel Data"><input type=text name="my_textarea2" size=70 value="no data collected yet"></form>
</body>
</html>
{
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
document.all.editdiv.innerHTML = Excel.Workbooks.Open(file).ActiveSheet.Cells(1,1).Value;
//Excel.Visible = true;
Excel.Quit();
}