从Excel复制/粘贴到网页 [英] Copy/Paste from Excel to a web page

查看:629
本文介绍了从Excel复制/粘贴到网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有标准的方式或库从Spreasheet复制并粘贴到Web表单?
当我从Excel中选择多个单元格时,我显然会丢失分隔符,并将所有单元格粘贴到Web窗体的一个单元格中。
是否必须在VB中完成?或者一旦在Web表单上开始粘贴操作,可以进行处理?

Is there a standard way or library to copy and paste from a spreasheet to a web form? When I select more than one cell from Excel I (obviously) lose the delimiter and all is pasted into one cell of the web form. Does it have to be done in VB? or could the processing be done once the paste action is started on the web form?

推荐答案

您不会丢失分隔符,单元格由制表符( \t )分隔,行按换行( \\\
)分隔,可能不是以形式可见。自己尝试:将内容从Excel复制到记事本,你会看到你的细胞很好地排列在一起。很容易,然后通过制表符分割字段,并用其他东西替换它们,这样你可以从它们构建一个表。这里有一个使用jQuery的例子:

You don't lose the delimiters, the cells are separated by tabs (\t) and rows by newlines (\n) which might not be visible in the form. Try it yourself: copy content from Excel to Notepad, and you'll see your cells nicely lined up. It's easy then to split the fields by tabs and replace them with something else, this way you can build even a table from them. Here's a example using jQuery:

var data = $('input[name=excel_data]').val();
var rows = data.split("\n");

var table = $('<table />');

for(var y in rows) {
    var cells = rows[y].split("\t");
    var row = $('<tr />');
    for(var x in cells) {
        row.append('<td>'+cells[x]+'</td>');
    }
    table.append(row);
}

// Insert into DOM
$('#excel_table').html(table);

因此本脚本从粘贴的Excel数据创建一个HTML表。

So in essence, this script creates an HTML table from pasted Excel data.

这篇关于从Excel复制/粘贴到网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆