Copy formatted Excel data to the clipboard from the Internet

I want to provide a button on my page so that when I click (excel formatted) the data will be copied to the user clipboard and they can paste excel with values ​​separated by columms. Is this possible maybe jquery? I have an understanding and experience with OOP.

Any help would be great.

+4
source share
2 answers

It seems hard to find a simple solution in JS that is a cross browser (this is just for IE, but not for another browser), so you can take a look at ZerClipboard, which is a good solution using Javascript and Flash.

Zeroclipboard

+3
source
function ClipBoard() { var tab = " "; var ticket = $('#Userid').text(); var queue = $('#queue').text(); var customer = $('#customer').text(); var res = $('#res').text(); var str = ticket+tab+queue+tab+customer+tab+res; $('#holdtext').append(str); Copied = holdtext.createTextRange(); Copied.execCommand("Copy"); } 

Using jquery and inserting tabs between each var will format for excel. However, this only works in IE.

 <TEXTAREA ID="holdtext" STYLE="display:none;"></TEXTAREA> <span id="ticket">767-45</span><br /> <span id="queue">john_doe</span><br /> <span id="customer">Citibank</span><br /> <span id="res">jan_doe</span><br /> <BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON> 
0
source

All Articles