Skip to content

Instantly share code, notes, and snippets.

@torjusb
torjusb / paste_excel.js
Created February 25, 2015 07:59
Handle pasted text from Excel, and split it into arrays of rows and columns
var clipboardData = window.clipboardData || event.clipboardData || event.originalEvent && event.originalEvent.clipboardData;
var pastedText = clipboardData.getData("Text") || clipboardData.getData("text/plain");
if (!pastedText && pastedText.length) {
return;
}
// Parse the pasted text from Excel into rows.
// Pasted text is usually separated by a new line for each row,