结合发票和数据工具来创建序列发票

结合发票和数据工具来创建序列发票

我想根据 CSV 表生成发票。我的方法如下:

\documentclass{letter}
\usepackage{invoice}
\usepackage{datatool}
\address{ABC AG \\
    Nonamestreet 4 \\
    1100 Vienna \\
    [email protected]}
\date{16. September 2013}
\begin{document}    
\DTLloaddb{bills}{billdata.csv}
\DTLforeach{bills}
{\firstname=firstname}
{\lastname=lastname}
{\caddress=customeraddress}
{\tariffname=tariffname}
{\service=service}
{\rateperunit=rateperunit}
{\unitcount=unitcount}
{
\begin{letter}{\firstname~ \lastname \\ \caddress}
\opening{Invoice}     Dear customer \lastname! This is your current bill.
\begin{invoice}{Euro}{20}
\ProjectTitle{\tariffname}
\Fee{Regular charge} {\rateperunit} {\unitcount}
\end{invoice}
\closing{Best regards, ABC AG}
\end{letter}
\clearpage
}
\end{document}

CSV 文件具有以下结构:

firstname   lastname    customeraddress tariffname  service rateperunit unitcount
John    Doe Musterstraße 4  Tariff1 Call    0.04    4
...

然后我.tex使用 PDFLaTeX 编译该文件。

但我总是收到这个错误:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...                                              

l.36 \NeedsTeXFormat{LaTeX2e}[
                           1995/12/01]
? 

! Emergency stop.
...                                              

l.36 \NeedsTeXFormat{LaTeX2e}[
                              1995/12/01]
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

我正在使用texliveUbuntu 13.04 的软件包,并且我也尝试使用它csvsimple,结果出现了完全相同的错误。

答案1

包含日期的错误的一部分已根据 @Ulrike Fischer 的评论进行了修复(通过在文件中替换\input{fp}\RequirePackage{fp}invoice.sty主要错误在\DTLforeach命令中。您不必为.csv文件中的每个字段添加一个参数,而是将它们全部分组到同一个参数中\DTLforeach

另外,在您的.csv文件中,您需要用 a 分隔字段,,而不是用空格。

\documentclass{letter}
\usepackage{invoice}
\usepackage{datatool}
\address{ABC AG \\
    Nonamestreet 4 \\
    1100 Vienna \\
    [email protected]}
\date{16. September 2013}
\begin{document}    
\DTLloaddb{bills}{billdata.csv}
\DTLforeach{bills}
{\firstname=firstname,
\lastname=lastname,
\caddress=customeraddress,
\tariffname=tariffname,
\service=service,
\rateperunit=rateperunit,
\unitcount=unitcount}
{
\begin{letter}{\firstname~ \lastname \\ \caddress}
\opening{Invoice}     Dear customer \lastname! This is your current bill.
\begin{invoice}{Euro}{20}
\ProjectTitle{\tariffname}
\Fee{Regular charge} {\rateperunit} {\unitcount}
\end{invoice}
\closing{Best regards, ABC AG}
\end{letter}
\clearpage
}
\end{document}

在此处输入图片描述

相关内容