问题描述
在ASP网页里的表格,想转化到excel里,并且在excel的格式要求固定,请各位高手帮帮忙,先谢了!
解决方案
解决方案二:
直接在网页上复制,粘贴到EXCEL里就行了.
解决方案三:
直接粘贴过去我们也试过,就是因为直接粘贴出来,很不规范,所以想做个模板出来,让网页中的数据固定从EXCEL的第几行第几列开始倒入!
解决方案四:
文件名:pubfun_SaveTool.asp<%ifRequest.ServerVariables("REQUEST_METHOD")="POST"thenResponse.Expires=-1Response.Buffer=truedimContent,savefilename,webfilename,atypeiftrim(request("cutechsavecontent"))<>""thensavefilename=trim(request.form("cutechSavefilename"))atype=trim(request.form("cutechtype"))Response.write(atype&"<br>")ifatype="excel"thenResponse.AddHeader"Content-disposition","attachment;filename="&savefilenameresponse.contenttype="application/vnd.ms-excel"elseifatype="word"thenResponse.AddHeader"Content-disposition","attachment;filename="&savefilenameresponse.contenttype="Application/msword"endifContent=trim(request("cutechsavecontent"))ifContent<>""thenResponse.write(content)endifendifendif%><SCRIPTLANGUAGE="javascript">functionSaveTool(){this.__saveFrom="";this.__fromType="file";//fileORtablethis.__saveType="excel"//excelORword}SaveTool.prototype.setSaveType=function(saveType){if(saveType=="excel"||saveType=="word"){this.__saveType=saveType;}else{alert("格式目前只能为'excel'OR'word'");}}SaveTool.prototype.getSaveType=function(){returnthis.__saveType;}SaveTool.prototype.setFromType=function(fromType){if(fromType=="file"||fromType=="table"){this.__fromType=fromType;}else{alert("格式目前只能为'file'OR'table'");}}SaveTool.prototype.getFromType=function(){returnthis.__fromType;}SaveTool.prototype.setSaveFrom=function(saveFrom){if(saveFrom!=""){this.__saveFrom=saveFrom;}else{alert("保存来源不能为空!");}}SaveTool.prototype.getSaveFrom=function(){returnthis.__saveFrom;}SaveTool.prototype.__WebFileDownloaded=function(source){//alert("到这里了");document.all["cutechsavecontent"].value=source;document.all["cutechsaveexcel"].submit();document.removeChild(document.all["cutechsaveexcel"]);}SaveTool.prototype.saveTo=function(savefilename){this.__aForm=document.createElement("<formname=cutechsaeexcelid=cutechsaveexcelaction='/share/pubfun_SaveTool.asp'method='post'></form>");this.__aText=document.createElement("<textareaname=cutechsavecontent></textarea>");this.__asfile=document.createElement("<inputtype=hiddenname=cutechSavefilename>");this.__atype=document.createElement("<inputtype=hiddenname=cutechtype>");this.__aForm.appendChild(this.__aText);this.__aForm.appendChild(this.__asfile);this.__aForm.appendChild(this.__atype);document.appendChild(this.__aForm);this.__atype.value=this.__saveType;if(this.__fromType=="file"){this.__asfile.value=savefilename;this.__aText.addBehavior('#default#download');this.__aText.startDownload(this.__saveFrom,this.__WebFileDownloaded);}elseif(this.__fromType=="table"){vartable=document.getElementById(this.__saveFrom);if(table){this.__aText.value=table.outerHTML;this.__asfile.value=savefilename;this.__aForm.submit();document.removeChild(this.__aForm);}else{alert("找不到指定的数据表:"+this.__saveFrom);}}else{alert("来源格式不正确,目前只能为'file'OR'table'");}}/*用法举例<!--#INCLUDEFILE="pubfun_SaveTool.asp"--><scriptlanguage="javascript">//保存成ExcelfunctionDoSavetoexcel(){varst=newSaveTool();//st.setSaveFrom("ToExcel_ShowDaily.asp?<%=request.serverVariables("QUERY_STRING")%>");st.setSaveFrom("saveexcel");st.setFromType("table");//还可以是filest.setSaveType=("excel");//保存成excel文件设置成word以保存成msword文件st.saveTo("<%=sDeptName%>_<%=sUserName%>_<%=Date()%>_日志");//保存文件}</script>*/</script>