代码:
submit()
{
var myTad = document.getElementById('rr');
var len = myTad.rows.length ;
var arr = [];
var values =[];
var key1 ="Task_NO";var key2 ="EFFORT_MONTH";var key3 ="ROLE";var key4 ="LOC"; var key5
="ESTIMATED_HOURS"; var key6 ="CNTY";
var key7 ="EMPLOYEE_LEVEL";var key8 ="AUTHENTED_HOURS";var key9 ="ESTIMATED_COST"; var key10
="ACTUAL_COST";
console.log("Row_length:" +len);
for( var z =0; z < len ; z++ )
{
for( var y = 0; myTad.rows[z].cells[y]; y++){
if(myTad.rows[z].cells[y].childNodes[0].getAttribute("type") == 'button'){
}else{
values.push(myTad.rows[z].cells[y].childNodes[0].value);
}
}
for(var k =0; k < values.length ;k++){
var dict = {};
dict[key1] = Number(values[0]);
dict[key2] =Number(values[1]);
dict[key3] = (values[2]);
dict[key4] = (values[3]);
dict[key5] = Number(values[4]);
dict[key6] = (values[5]);
dict[key7] = Number(values[6]);
dict[key8] = Number(values[7]);
dict[key9] = Number(values[8]);
dict[key10] = Number(values[9]);
}
arr.push(dict);
dict ={};
values =[];
}
}
uploadExcel()
{
var arr= [];
var myfile = document.getElementById('file');
var input = myfile;
var reader =new FileReader();
reader.onload = function(){
var fileData =reader.result;
var workbook = XLSX.read(fileData, {type:'binary'});
workbook.SheetNames.forEach(function(sheetName){
var rowObject = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
var json_object = JSON.stringify(rowObject);
arr = rowObject;
});
//debugger;
for(var i=0;i<arr.length;i++){
var data=arr[i];
$("#customFields tbody").empty();
//$("#customFields tfoot").append("<tr style='text-align:center;'><td style='border:1px
solid black;'><input type='text' value="+data.TASK_NO+"></td><td style='border:1px solid
black;'><input type='text' value="+data.EFFORT_MONTH+"></td><td style='border:1px solid
black;'><input type='text' value="+data.EMPLOYEE_LEVEL+"></td><td style='border:1px solid
black;'><input type='text' value="+data.ROLE+"></td><td style='border:1px solid black;'><input
type='text' value="+data.LOCATION+"></td><td style='border:1px solid black;'><input type='text'
value="+data.ESTIMATED_HOURS+"></td><td style='border:1px solid black;'><input type='text'
value="+data.COUNTRY+"></td><td style='border:1px solid black;'><input type='text'
value="+data.AUTHENTED_HOURS+"></td><td style='border:1px solid black;'><input type='text'
value="+data.ESTIMATED_COST+"></td><td style='border:1px solid black;'><input type='text'
value="+data.ACTUAL_COST+"></td></tr>");
$("#customFields tfoot").append("<tr style='text-align:center;' contenteditable='true'><td
style='border:1px solid black;'>"+data.TASK_NO+"</td><td style='border:1px solid
black;'>"+data.EFFORT_MONTH+"</td><td style='border:1px solid black;'>"+data.EMPLOYEE_ROLE+"</td>
<td style='border:1px solid black;'>"+data.LOCATION+"</td><td style='border:1px solid
black;'>"+data.ESTIMATED_HOURS+"</td><td style='border:1px solid black;'>"+data.COUNTRY+"</td><td
style='border:1px solid black;'>"+data.EMPLOYEE_LEVEL+"</td><td style='border:1px solid
black;'>"+data.AUTHENTED_HOURS+"</td><td style='border:1px solid black;'>"+data.ESTIMATED_COST+"
</td><td style='border:1px solid black;'>"+data.ACTUAL_COST+"</td></tr>");
}
};
reader.readAsBinaryString(input.files[0]);
}
初始表不包含行,如果要解决此错误,请设法在上面创建行错误,但请帮忙...如果我要一次,请及时进行此问题的发生更改并成功完成。我无法理解此问题...
ERROR in src/app/app.component.ts(50,20): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(59,27): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(60,15): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(63,25): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(98,20): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(109,27): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(113,26): error TS2339: Property 'rows' does not exist on type 'HTMLElement'. src/app/app.component.ts(172,31): error TS2339: Property 'sheet_to_row_object_array' does not exist on type 'XLSX$Utils'. src/app/app.component.ts(186,36): error TS2339: Property 'files' does not exist on type 'HTMLElement'.