单击即可以富文本格式复制HTML表

单击即可以富文本格式复制HTML表

本文介绍了单击即可以富文本格式复制HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将HTML表作为多格式文本从页面复制到剪贴板,并准备单击即可将内容粘贴到excel中.

I want to copy the HTML table from my page as rich text to clipboard and be ready to paste the contents in excel on a single click.

我在Stackoverflow中找到了很棒的代码选择包含Javascript的完整表格(要复制到剪贴板)

I found a awesome code in StackoverflowSelect a complete table with Javascript (to be copied to clipboard)

但是,上面的代码将仅选择表中的内容.任何人都可以帮助调整代码以使其以富文本格式复制表格(表格单元格包含颜色并且需要复制)并将其粘贴到excel或任何其他兼容窗口中.

However, the above code will only select the content in the table. Can any one please help to tweak the code to make it to copy table as rich text (table cells contains color and need to be copied) and paste it in excel or any other compatible window.

推荐答案

由于浏览器是沙盒环境,大多数浏览器通常都无法将其复制到系统剪贴板中(IE是一个已知的例外),这就是您所需要的.想要没有闪光灯的帮助.如果您仍要复制,则可以使用ZeroClipboard来辅助此操作.否则,建议您指导用户按Ctrl + C进行复制.

Because a browser is a sand-boxed environment is usually rendered impossible by most browsers (IE a known exception) to copy to the system's clipboard, which is what you want without the aid of flash. You can use ZeroClipboard to aid in this if you still want to copy. Otherwise I suggest instructing users to press Ctrl+C to copy.

请参阅以下相关文章:.

See this related post: HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?.

这篇关于单击即可以富文本格式复制HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 07:21