无法截断长表中某一行的总和

无法截断长表中某一行的总和

在此处输入图片描述

我能够使用\DTLtrunc命令截断最后一行,但此命令不适用于截断最后一列的数字,这是我的 MWE。

\documentclass[10pt,a4paper,landscape]{article}
\usepackage[left=1cm]{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}

 \usepackage{siunitx}
 \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}
\usepackage{tabularcalc,spreadtab}

\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

\DTLiffirstrow{}{\\\hline}  %
\IfSubStr{\id}{ABC}{\stepcounter{Serial}}{}
\IfInteger{\theSerial}{\stepcounter{SerialN}}{}

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

\end{longtable}
\end{document}

答案1

你没有给出任何截断数字的指令

\DTLaddall{\total}{\jan,\feb,\mar,\apr,\may,\jun,\jul,\aug,\sep,\oct,\nov,\dec}\total

只需添加\DTLtrunc

\DTLaddall{\total}{\jan,\feb,\mar,\apr,\may,\jun,\jul,\aug,\sep,\oct,\nov,\dec}%
\DTLtrunc{\total}{\total}{2}\total

相关内容