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==4){
            row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
                if(colNumber==1){
                    // var tt=cell.value.richText[0].text;
                    var rptDate=getMonth("GT",cell);
                    toparsedate.rptDate=rptDate;
                }
            });
        }
        if(rowNumber>=10 && rowNumber<=47){
          var rowDesc="";
          var cacheStr="";
          row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
              if(colNumber==2){
                  if(typeof cell.value=="object"){
                    cell.value.richText.forEach(element => {
                      rowDesc+=element.text.replace(" ","");
                    });
                  }else{
                      rowDesc+=cell.value.replace(" ","");
                  }     
                  cacheStr=rowDesc;
              }
              if(colNumber==19 || colNumber==26 || colNumber==36 || colNumber==40){
                  var colPos=1;
                  var buildRow={};
                  if(colNumber==19 || colNumber==26){
                      rowDesc=rowDesc+"/"+"一般项目";
                  }
                  if(colNumber==36 || colNumber==40){
                      rowDesc=rowDesc+"/"+"即征即退项目";
                  }
                  if(colNumber==19){
                      rowDesc+="/"+"本月数";
                      colPos=1;
                  }
                  if(colNumber==26){
                      rowDesc+="/"+"本年累计";
                      colPos=2;
                  }
                  if(colNumber==36){
                      rowDesc+="/"+"本月数";
                      colPos=3;
                  }
                  if(colNumber==40){
                      rowDesc+="/"+"本年累计";
                      colPos=4;
                  }
                  buildRow.rpttypecode="GT";
                  buildRow.position=rowNumber+"-"+colPos;
                  buildRow.desc=rowDesc.trim();
                  buildRow.valstr=cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                  insertrows.push(buildRow);
                  rowDesc=cacheStr;
              }
            });
        }
    });
    return insertrows;
});