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==5){
            row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
                if(colNumber==1){
                    // var tt0=cell.value.richText[0].text;
                    // var tt1=cell.value.richText[1].text;
                    // var tt2=cell.value.richText[2].text;
                    // var tt=tt0+tt1+tt2;
                    var rptDate=getMonth("ST",cell);
                    toparsedate.rptDate=rptDate;
                }
            });
        }
        if(rowNumber>=9 && rowNumber<=33){
        
          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==5 || colNumber==6 || colNumber==7 || colNumber==8){
                  var colPos=1;
                  var buildRow={};
                  if(colNumber==5 || colNumber==6){
                      rowDesc=rowDesc+"/"+"本期数";
                  }
                  if(colNumber==7 || colNumber==8){
                      rowDesc=rowDesc+"/"+"本年累计";
                  }
                  if(colNumber==5){
                      rowDesc+="/"+"货物及劳务";
                      colPos=1;
                  }
                  if(colNumber==6){
                      rowDesc+="/"+"服务、不动产和无形资产";
                      colPos=2;
                  }
                  if(colNumber==7){
                      rowDesc+="/"+"货物及劳务";
                      colPos=3;
                  }
                  if(colNumber==8){
                      rowDesc+="/"+"服务、不动产和无形资产";
                      colPos=4;
                  }
                  buildRow.position=rowNumber+"-"+colPos;
                  buildRow.desc=rowDesc;
                  buildRow.valstr=cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
                  insertrows.push(buildRow);
                  rowDesc=cacheStr;
              }
            });
        }
    });
    return insertrows;
});