0

I don't know why this happen in longtable its generated extra row at the bottom of the table which is unwanted row, Please somebody help me to solved this problem here is my MWE

\documentclass[10pt,a4paper]{article}
 \usepackage[left=0.5cm]{geometry}
\usepackage{datatool}

\usepackage{filecontents}
\usepackage{siunitx}
\usepackage[all]{tcolorbox}
 \usepackage{graphicx,booktabs,xstring,datatool,xintexpr,longtable} %for including eps graphics
 \usepackage{multirow,colortbl,xfp}


\begin{filecontents}{data.csv}
ID,Name,January,February,March,April,May,June,July,August,September,October,November,December
ABC01,Mr. ABC,1,3432,54,54,54,56,54,54,54,54,54,54.25
ABC02,Mr. ABC,2,354,234,234,234,80,234,234,234,234,234,234
ABC03,Mr. ABC,1,544,343,343,343,0,343,343,343,343,343,343
ABC04,Mr. ABC,0,3423,343,343,0,0,343,343,343,343,343,343
ABC05,Mr. ABC,1,34,434,434,0,0,434,434,434,434,434,434
ABC06,Mr. ABC,2,0,42,42,0,0,42,42,42,42,42,42
ABC07,Mr. ABC,25,0,3432,3432,0,0,3432,3432,3432,3432,3432,3432
ABC08,Mr. ABC,23,0,343,343,343,0,343,343,343,343,343,343
ABC09,Mr. ABC,12,0,43,43,43,0,43,43,43,43,43,43
ABC10,Mr. ABC,0,0,90,90,90,0,90,90,90,90,90,90
     ,Mr. ABC,34,0,0,0,0,0,0,0,0,0,0,0
     ,Mr. ABC,44,12,0,0,0,0,0,0,0,0,0,0
\end{filecontents}
\newcounter{Serial}
\newcounter{SerialN}

 \DTLloaddb{name}{data.csv}
\begin{document}



\centering


\edef\numberofrows{\DTLrowcount{name}}%
\DTLsumcolumn{name}{January}{\JanT}
\DTLsumcolumn{name}{February}{\FebT}
\DTLsumcolumn{name}{March}{\MarT}
\DTLsumcolumn{name}{April}{\AprT}
\DTLsumcolumn{name}{May}{\MayT}
\DTLsumcolumn{name}{June}{\JunT}
\DTLsumcolumn{name}{July}{\JulT}
\DTLsumcolumn{name}{August}{\AugT}
\DTLsumcolumn{name}{September}{\SepT}
\DTLsumcolumn{name}{October}{\OctT}
\DTLsumcolumn{name}{November}{\NovT}
\DTLsumcolumn{name}{December}{\DecT}


\begin{longtable}{|c|l|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\rowcolor{green!20}\bf\rotatebox{90}{\hspace*{1mm}Sl.~No.} & \bf{\raisebox{3.5ex}{Name}} & \bf\rotatebox{90}{January}& \bf\rotatebox{90}{February}& \bf\rotatebox{90}{March} & \bf\rotatebox{90}{April}&\bf\rotatebox{90}{May} & \bf\rotatebox{90}{June} & \bf\rotatebox{90}{July} & \bf\rotatebox{90}{August} & \bf\rotatebox{90}{September}& \bf\rotatebox{90}{October} & \bf\rotatebox{90}{November} & \bf\rotatebox{90}{December}& \bf{\raisebox{4ex}{Total}}\\\hline \endhead

\DTLforeach*{name}{\name=Name,\jan=January,\feb=February,\mar=March,\apr=April,\may=May,\jun=June,\jul=July,\aug=August,\sep=September,\oct=October,\nov=November,\dec=December,\id=ID}{% build table


\IfSubStr{\id}{DBC}{\stepcounter{Serial}}{}
\IfInteger{\theSerial}{\stepcounter{SerialN}}{}

\theSerialN &\name&\jan&\feb&\mar&\apr&\may&\jun&\jul&\aug&\sep&\oct&\nov&\dec&\\\hline
}\\\bottomrule
\multicolumn{2}{|c|}{\it Total} & \JanT&\FebT&\MarT&\AprT&\MayT&\JunT&\JulT&\AugT&\SepT&\OctT&\NovT&\DTLtrunc{\result}{\DecT}{2}\result& \\     \hline

\end{longtable}

\end{document}

enter image description here

Biki Teron
  • 3,275
  • Remove \\ before your first \bottomrule and that as well. – TeXnician May 18 '17 at 08:18
  • No its not working its give me error with red text ! Misplaced \noalign.@TeXnician – Biki Teron May 18 '17 at 08:20
  • 1
    Well, that's because your DTLforeach is treated as the first element (first column) in that new row. – TeXnician May 18 '17 at 08:22
  • How do I solve that row @TeXnician ? – Biki Teron May 18 '17 at 08:23
  • 1
    isn't this identical to the question you asked yesterday? https://tex.stackexchange.com/questions/370077/how-do-i-remove-blank-rows-created-in-longtable – David Carlisle May 18 '17 at 08:50
  • Yes its similar but the coding is confussion so could not tackle the problem, however after searching through text.stackexchange, i found with good solution \DTLiffirstrow{}{\\hline} https://tex.stackexchange.com/questions/42554/datatool-with-longtable @DavidCarlisle – Biki Teron May 18 '17 at 09:04

0 Answers0