一、最简单的方法
你可以直接选中表单数据直接复制粘贴到excel表格中或者新建文档中,然而这样仅仅只有数据,没有任何样式。
二、另存为
在需要转换成文档的页面中,右键选择网页另存为html文件。
例如我在网页上随便找一个表单数据。
另存网页html格式,然后用excel打开。
然后在excel中选择显示或取消网格线,就可以在表格中看到完整数据。
三、用js方法
<script type="text/javascript"> function exportexcel() {var shtml = htmlencode($("#mystamp")[0].outerhtml);$("input[name='hhtml']").val(shtml); $("form[name='myform']").submit(); } function htmlencode(value) { //create a in-memory div, set it's inner text(which jquery automatically encodes) //then grab the encoded contents back out. the div never exists on the page. return $('<div/>').text(value).html(); } </script>
这种方法可以通过点击一个按钮就能直接将html表单页面导出成word即html转换word文档,但是这里需要注意一下,想要导出有边框样式的表单文档,需要把样式直接写到标签里面,不要使用css,写到style属性里即可。
注:htmlencode是将html源文件中不容许出现的字符进行编码,通常是编码以下字符:9f69b873d3534bc1b95032470265b196、&、、'等;
【相关文章推荐】
表单元素:最全的各种html表单元素获取和使用方法总结
带你掌握html中table和form表单
html表单知识大全
用html中标签制作表单实例
以上就是html表单数据怎么转换成word文档?(示例)的详细内容。
