1

This question already has an answer here:

I am trying to create a report in table format and values in table have to input from some external file (or excel file). Can this be achieved in Latex? If yes, then the number of table rows should be auto increment according to input data. I tried using \longtablebut could not succeed. following is my code.

\documentclass{article}
\usepackage[a4paper,margin=0.7 in,landscape]{geometry}
\usepackage{array}
\usepackage[thinlines]{easytable}
\usepackage{geometry}
\usepackage{fancyhdr, graphicx}
\usepackage{tabulary}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{float}
\usepackage{ltablex} 
\pagestyle{fancy}
\setlength\headheight{30pt}
\fancyhead[L]{\begin{tabular}{lll}
          %  \hline
            \multirow{2}{*}{\includegraphics[width=30pt]{logo.jpg}} &          \multicolumn{1}{l}{\textbf{Variable Messsage Sign Report}}  \\
                             & \multicolumn{1}{l}{Downloaded by USER on DATE and TIME}  
\end{tabular}\\}
\cfoot{\thepage\ / \pageref{LastPage}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\makeatletter
\setlength{\@fptop}{0pt}
\begin{document}
\begin{figure}
    \centering
    \includegraphics[width=0.3\linewidth]{hcc.jpg}
\vspace{-100 px}
\end{figure}
\vspace{-400 px}
\begin{table}[]
\textbf{Variable Message Sign Summary} \\
\centering
\noindent\begin{minipage}[t][4in][t]{\textwidth}
\centering
\bgroup
\def\arraystretch{2}
\begin{longtable}[100pt]    {|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|}
\hline 
\textbf{Status} & \textbf{SCN} & \textbf{Slide} & \textbf{Message\_Text} &     \textbf{Time} & \textbf{Created\_by} & \textbf{Created\_on} &     \textbf{Updated\_on} & \textbf{Deleted\_on} \\ \hline
 &sdfgdfsgdfsg dfg dfgdfgdfg d &  &  &  &  &  &  &    \\ \hline
 &gfdgdfgdf  fgdfgdf sdfgg   &  &  &  &  &  &  &    \\ \hline
 &  dfgfdg dfgdfg dffgdfg &  &  &  &  &  &  &    \\ \hline
 &  dfgdfgd dfgdfg dfgdfg&  &  &  &  &  &  &    \\ \hline
 & fgdfg dffgdfgdf dffgdf  &  &  &  &  &  &  &    \\ \hline
 &  dfgdfgd dfgdfg dfgdfg&  &  &  &  &  &  &    \\ \hline
 & fgdfg dffgdfgdf dffgdf  &  &  &  &  &  &  &    \\ \hline
 & fgdfg dffgdfgdf dffgdf  &  &  &  &  &  &  &    \\ \hline
 &gfdgdfgdf  fgdfgdf sdfgg   &  &  &  &  &  &  &    \\ \hline
 &  dfgfdg dfgdfg dffgdfg &  &  &  &  &  &  &    \\ \hline
 &  dfgdfgd dfgdfg dfgdfg&  &  &  &  &  &  &    \\ \hline
 & fgdfg dffgdfgdf dffgdf  &  &  &  &  &  &  &    \\ \hline
\end{longtable}
\egroup
\end{minipage}
\end{table}
\end{document}

PS: pardon for using some packages which are not useful here

Attached is the screenshot of what I am getting as an output.enter image description here

marked as duplicate by gernot, Zarko, Guilherme Zanotelli, Werner tables Dec 13 '16 at 16:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Hi, welcome. If you know that some packages are not useful/relevant, why not just remove them from the example? And by the way, the whole point of a longtable is that it can break across pages, when you put it inside a minipage page breaks are no longer possible. – Torbjørn T. Dec 13 '16 at 14:12
  • Use e.g. the csvsimple package. Then you can convert a csv file to a tabular with a single command. – gernot Dec 13 '16 at 14:28
  • @TorbjørnT. So I removed minipage now, but still the rows are mixing up with the footer and no page break is generated. – Sanket Thorat Dec 14 '16 at 5:27
  • Oops, didn't notice that you have a table environment as well. That also needs to go. And you probably want to remove the negative vspaces. – Torbjørn T. Dec 14 '16 at 7:20