\usemodule[handlecsv]
\opencsvfile{systaprov2.csv}
\setuppapersize[A4, landscape]
\setuplayout[location=middle, width=27.5cm, height=18cm, backspace=1cm,header=4cm]
\setuppagenumbering[state=stop]
\setupcaptions[location=none]
\setupbackgrounds[header][text][background={Logos}, state=repeat]
\setupnumbering [location=]
\setupframed[offset=none]
\defineoverlay
[Logos][{
\framed[width=\textwidth,
height=3cm,
align=right,
strut=no,
offset=none,
frame=on,
frameoffset=0.1cm,
corner=round,
radius=0.15cm,
framecolor=darkgray,
background=color,
backgroundcolor=gray,
framecorner=round,
frameradius=0.15cm,
rulethickness=0.05cm]{
\framed[width=0.280\textwidth,
height=3cm,
align=right,
frame=off]
{\placefigure[force][]{none}{\externalfigure[somepic.png][height=1.9cm]} }
\framed[width=0.430\textwidth,
height=3cm,
align=middle,
frame=off]
{\crlf\tfa \crlf \bf Technical Report}
\framed[width=0.370\textwidth,
height=3cm,
align=middle,
frame=off]
{\tfx \crlf Annex T.2.3. \crlf \tfx Date of issue: \crlf \currentdate \crlf page \pagenumber of \lastpage}
}
}]
%\setupfloat[table][default={force,split}]
\setupxtable[offset=0cm,
frame=off,
bottomframe=on,
framecolor=gray,
option=stretch,
split=yes,
header=repeat,
align=middle]
\setupxtable[head][background=color,
backgroundcolor=gray,
topframe=on,
bottomframe=on,
framecolor=black,
foregroundcolor=blue]
\setupxtable[left][align=right]
\starttext
Some lines of text. This text must come just before the table, but only on the first page of the table
\startbuffer[loop]
\startxrow
\startxcell[left] \cA \stopxcell
\startxcell[left] \cB \stopxcell
\startxcell[left] \cC \stopxcell
\startxcell[left] \cD \stopxcell
\startxcell \cE \stopxcell
\startxcell[left] \cF \stopxcell
\startxcell \cG \stopxcell
\startxcell \cH \stopxcell
\doifdefined{cI}{\startxcell \cI \stopxcell}
\doifdefined{cJ}{\startxcell \cJ \stopxcell}
\doifdefined{cK}{\startxcell [left] \cK \stopxcell}
\stopxrow
\stopbuffer
%\startplacetable[]
\startxtable
\startxtablehead[head]
\doloopif{\lineno}{<}{2}{\getbuffer[loop]}
\stopxtablehead
\startxtablebody
\doloopif{\lineno}{>}{1}{\getbuffer[loop]}
\stopxtablebody
\stopxtable
%\stopplacetable
\stoptext