Grep Data Base on Column

HI

Want to grep data from column header and match with second file.

File	A.txt					
						
	1	2	3	4	5	6
X1	A	L	D	J	Q	R
X2	B	M	K	P	w	T
X3	C	S	L	P	e	Y
X4	R	Z	M	A	r	U
						
						
FileB.txt						
1						
2						
3						
4						
6						
7						
						
						
FileC.txt						
						
	1	2	3	4	6	7
X1	A	L	D	J	R	n/a
X2	B	M	K	P	T	n/a
X3	C	S	L	P	Y	n/a
X4	R	Z	M	A	U	n/a

Any attempts/ideas/thoughts from your side?

Here is one.

awk '
(NR==FNR) {
# File1, read into array
  col[++colmax]=$1
  next
}
{
# File2
  if (FNR==1) {
    offset=0
  } else {
# print the first column; the addressed columns are +1
    printf "%s", $1
    offset=1
  }
# print the columns in the order of col[]
  for (c=1; c<=colmax; c++) {
    pos=offset+col[c]
    printf "%s%s", "\t", (pos>NF) ? "-" : $pos
  }
  printf "\n"
}
' FileB.txt FileA.txt

Well, I had this one, but waited for OP's attempts/ideas/thoughts:

awk '
FNR == NR       {COL[++CNT]=$1
                 next
                }
FNR == 1        {printf "%-8s", ""
                 for (i=1; i<=CNT; i++) printf "%-8s", COL
                 printf "\n"
                 next
                }
                {printf "%-8s", $1
                 for (i=1; i<=CNT; i++) printf "%-8s", $(COL+1)?$(COL+1):"n/a"
                 printf "\n"
                }
' file2 file1
        1       2       3       4       6       7       
X1      A       L       D       J       R       n/a     
X2      B       M       K       P       T       n/a     
X3      C       S       L       P       Y       n/a     
X4      R       Z       M       A       U       n/a