Another method is to use flash, which avoids the security restrictions of the browser, but the system class has only set methods, and other clipboard classes are accessible, but it seems to need FLASH10 version support.
Find a lap on the internet, nothing to find. Finally thought of to see how Google sheet is done.
Found that Google sheet implemented the plain text of Excel by most of the grid paste, no security restrictions required, no use of flash. Probably a lot of people know this method, anyway, I was surprised at first, but helpless, Google's JS file is handled, looks too tired. Then go to find Zoho sheet, it's JS file only a simple deal, can debug, can see.
Originally, it registered in the body of the onkeydown event, when the user press CTRL + V button, JS will focus on a textarea label, so that the next keypress and KeyUp incident occurred in the textarea, Naturally, the equivalent of the user in the textarea copy a bit, and then, JS then shifted focus, from textarea to the value. This takes you to the Clipboard text data.
Here is a little example of a simulation of Zoho sheet implementations.
Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<script type= "Text/javascript" ><!--
function Cellkeydown (event) {
if (event.ctrlkey && event.keycode = 86) {
var ss = document.getElementById ("TextArea");
Ss.focus ();
Ss.select ();
Wait 50 milliseconds, KeyPress event occurs and then process the data.
SetTimeout ("Dealwithdata ()", 50);
}
}
function Dealwithdata (event) {
var ss = document.getElementById ("TextArea");
alert (Ss.value);
Ss.blur ();
}
--></script>
<body onkeydown= "return Cellkeydown (Event)" >
<div>
<textarea id= "textarea" >
The obtained Excel text data, according to the \t,\n can divide the lattice and the line information. But this can only be a simple plain text of the Excel value, the grid style can not get. But I found a way to copy the document to the IFRAME (the way the online editor is implemented), so that there are some style information, ie in particular, it is estimated that their own products can be resolved by the product itself, FF and Chrome can only get a few simple attributes, such as the column width of the line. I don't know who has the means to get a more complete message.