![](/img/trans.png)
[英]How to paste vaues from excel sheet to table and store it in state in React?
[英]display a table from a excel sheet
我想在我的html页面中显示excel表格中的表格。 Excel工作表中有多个表。 我想要显示一个特定的表。 请帮忙..
我用来从excel文件中提取信息的HTML代码
<html>
<head>
<title>
From Excel
</title>
<script language="javascript" >
function GetData(cell,row){
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("C:\\abc.xlsx");
var excel_sheet = excel.Worksheets("25 PEs");
var data = excel_sheet.Cells(cell,row).Value;
document.getElementById('div1').innerText =data;
}
</script>
</head>
<body>
<div id="div1" style="background: #DFDFFF; width:'100%';" align="center">
Click buttons to fetch data from c:\abc.xlsx
</div>
<input name="Button1" type="button" onClick="GetData(1,1)" value="button1">
<input name="Button2" type="button" onClick="GetData(1,2)" value="button2">
<input name="Button3" type="button" onClick="GetData(2,1)" value="button3">
<input name="Button4" type="button" onClick="GetData(2,2)" value="button4">
</body>
</html>
此代码一次提取一个单元格。 我想一次提取整个表格。 怎么做?
一个很好的选择是使用jquery库dataTables。 然后,您可以使用DataConverter先生提供的工具将您的电子表格转换为json。 然后,您将数据表指向json文件,过滤掉您不需要的任何列,以及中提琴,您的数据显示在一个漂亮的html表中,并根据您的喜好进行自定义。 我最近才使用这种方法,它使显示大量数据变得更加容易。
DataTables - http://www.datatables.net/
数据转换器先生 - http://www.shancarter.com/data_converter/index.html
隐藏单个列的代码在dataTables intializer中看起来像这样:
"aoColumnDefs" : [{
"bVisible" : false,
"bSearchable": true,
"aTargets" : [0, 1, 4, 6, 9, 10, 11, 12]
}
并重新排序列将看起来像:
"aoColumns": [//reorder the columns
{ "mDataProp": [0] },
{ "mDataProp": [1] },
{ "mDataProp": [2] },
{ "mDataProp": [7] },
{ "mDataProp": [4] },
],
希望这个对你有帮助...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.