var getMonth=require("./getMonth");
module.exports = (async (wb,toparsedate) => {
    var sheet = wb.getWorksheet(1);
    var insertrows = [];
    sheet.eachRow({ includeEmpty: true }, function (row, rowNumber) {
        if(toparsedate.isparsedate && rowNumber==2){
            row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
                if(colNumber==1){
                    //var tt=cell.value.richText[0].text;
                    var rptDate=getMonth("ITQ",cell);
                    toparsedate.rptDate=rptDate;
                }
            });
        }
        if (rowNumber >= 13 && rowNumber <= 27) {
            row.eachCell({ includeEmpty: true }, function (cell, colNumber) {
                if (colNumber == 2) {
                    if (typeof cell.value == "object") {
                        desc = "";
                        cell.value.richText.forEach(element => {
                            desc += element.text.replace(" ","");
                        });
                    } else {
                        desc = cell.value.replace(" ","");
                    }
                }
                if (colNumber == 11) {
                    var buildRow = {};
                    buildRow.rpttypecode = "ITQ";
                    buildRow.valstr = cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                    buildRow.desc = desc + "/本年累计金额";
                    buildRow.position = rowNumber + "-" + 1;
                    insertrows.push(buildRow);
                }
            });
        }
        if (rowNumber >= 29 && rowNumber <= 34) {
            row.eachCell({ includeEmpty: true }, function (cell, colNumber) {
                if (colNumber == 4) {
                    if (typeof cell.value == "object") {
                        desc = "";
                        cell.value.richText.forEach(element => {
                            desc += element.text.replace(" ","");
                        });
                    } else {
                        desc = cell.value.replace(" ","");
                    }
                }
                if (colNumber == 11) {
                    var buildRow = {};
                    buildRow.rpttypecode = "ITQ";
                    buildRow.valstr = cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                    buildRow.desc = desc + "/本年累计金额";
                    buildRow.position = rowNumber + "-" + 1;
                    insertrows.push(buildRow);
                }
            });

        }
        if (rowNumber >= 39 && rowNumber <= 40) {
            row.eachCell({ includeEmpty: true }, function (cell, colNumber) {
                if (colNumber == 1) {
                    if (typeof cell.value == "object") {
                        desc = "";
                        cell.value.richText.forEach(element => {
                            desc += element.text.replace(" ","");
                        });
                    } else {
                        desc = cell.value.replace(" ","");
                    }
                }
                if (colNumber == 5) {
                    var buildRow = {};
                    buildRow.rpttypecode = "ITQ";
                    buildRow.valstr = cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                    buildRow.desc = desc;
                    buildRow.position = rowNumber + "-" + 1;
                    insertrows.push(buildRow);
                }
                if (colNumber == 8) {
                    if (typeof cell.value == "object") {
                        desc = "";
                        cell.value.richText.forEach(element => {
                            desc += element.text.replace(" ","");
                        });
                    } else {
                        desc = cell.value.replace(" ","");
                    }
                }
                if (colNumber == 11) {
                    var buildRow = {};
                    buildRow.rpttypecode = "ITQ";
                    buildRow.valstr = cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                    buildRow.desc = desc;
                    buildRow.position = rowNumber + "-" + 2;
                    insertrows.push(buildRow);
                }
            });

        }

    });
    return insertrows;
});