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==3){
            row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
                if(colNumber==1){
                    // var tt1=cell.value.richText[1].text;
                    // var tt2=cell.value.richText[2].text;
                    // var tt=tt1+tt2;
                    var rptDate=getMonth("SP",cell);
                    toparsedate.rptDate=rptDate;
                }
            });
        }
        if(rowNumber>=5 && rowNumber<=38){
          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==3 || colNumber==4){
                          var buildRow={};
                          buildRow.rpttypecode="SP";
                          buildRow.valstr=cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                          if(colNumber==3){
                              buildRow.desc=desc+"/本年累计金额";
                              buildRow.position=rowNumber+"-"+1;
                          }else{
                              buildRow.desc=desc+"/本月金额";
                              buildRow.position=rowNumber+"-"+2;
                          }
                          insertrows.push(buildRow);
                 }
            });
        }
    });
    return insertrows;
});