如何在单击按钮时将Excel文件作为弹出窗口打开

问题描述:

如何在单击按钮时以弹出形式打开excel文件.单击按钮时我需要在excel工作表中显示数据库数据.我能够将数据保存在excel工作表中的某个位置,但是

how to open excel file as a popup on click of a button.On click of a button i need to display the database data in an excel sheet.i am able to save the data in an excel sheet at some location but its not opening as a popup.i need to open the sheet once i click the the button.

您可以阅读有关打开excel文件的更多信息 ^ ].
完成此操作后,您可以在此处 [ ^ ].
You can read more about opening an excel file here[^].
Once you are done with that, you can take a look at opening the popup here[^].


一种方法是将onclick处理程序附加到按钮.然后在客户端使用JavaScript,使用window.open方法并将其传递给文件URL.

如果这不是您想要的,则可能需要通过选择改进问题"链接来为问题添加更多详细信息.
One of the ways would be to attach an onclick handler to the button. And on client side using JavaScript, use window.open method and pass it the file URL.

If this is not what you want, you may need to add more details to your question by selection ''improve question'' link.


一种简单的方法是使用超链接并直接打开excel.

a simple is to use hyperlink and open excel directly.

<a href="bank/sheet.xls" >some excel file</a> 



或使用Javascript



OR use Javascript

<script type="text/javascript">
 	function openFile(strFilePath)
        {
		var objExcel;
                //Create EXCEL object
		objExcel = new ActiveXObject("Excel.Application");
		objExcel.Visible = true;
		objExcel.Workbooks.Open(strLocation, false, false);
	}
</script>