## Creating pgfgantt Calendars for 2013 with Excel

The pgfgantt package is a great tool to create Gantt charts, that are quite useful in the management of projects since one can visualize task dependencies with their help.

To get to know this package a little better I have –with the help of stackexchange— created a calendar for 2013 (PDF), showing the 365 days with SAT & SUN highlighted.

To add an entry to the calendar however I need to calculate the number of the day for the start and end date — a task Excel is quite good at. I played a little and finally came up with an Excel file that allows me to enter the start and end dates plus the name of the Gantt-bar and puts then together the string for the Gantt-bar.

The first columns are pretty self-explaining, the „description“ column is not exported to the LaTeX code. All the magic happens in the final column, let’s look at some example (Excel file):

 ="\ganttbar" & WENN([@Color]<>"";"[bar/.style={fill=" & [@Color] &"}]";) &"{" &[Name] & "}{"& C3-41274&"}{"&D3-41274&"}" & WENN([@Name]=B4;"";"\\") 

It is basically just a concatenation of strings with some IF („WENN“ in German) and date calculation. The first WENN is used to determine if the color has been set. If it is set, some brackets need to be printed with the bar/fill stuff. The Name of the bar is printed, then I calculate the differences from the first date and the number 41274 (corresponds to Deember 31st in Excel number format) and the second date and the number 41274. Since I can have more than one bar in one line I check if the line below has the same name. If it has, no „\\“ shall be printed, if it is different I want to finish this line. I can then copy the generated code directly into my LaTeX file:

\documentclass{article} \usepackage[paperwidth=160cm, paperheight=50cm, left=1cm,right=1cm,top=5cm,bottom=5cm]{geometry} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{pgfgantt} \usetikzlibrary{calendar}   \protected\def\zzz#1{% \pgfcalendarifdate{2012-12-31+#1}{weekend}% Test if it's a weekend {\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color {\pgfcalendarifdateday}% Or just the number }   \begin{document}   \begin{ganttchart}[hgrid, vgrid, x unit=0.425cm]{365} \gantttitle{Projektplan}{365} \\ \gantttitlelist[ title list options={var=\y, evaluate=\y as \x using {"\zzz{\y}"}} ]{1,...,365}{1} \\ \ganttbar[bar/.style={fill=yellow}]{public holiday}{8}{8}\\ \ganttbar{some conference}{65}{67}\\ \ganttbar[bar/.style={fill=blue}]{some date}{36}{49} \ganttbar[bar/.style={fill=green}]{some date}{51}{55}\\ \end{ganttchart}   \end{document}

Deutsche Zusammenfassung: Die Erstellung von Einträgen für pgfgantt-basierte Kalender kann man deutlich vereinfachen, wenn man in einer Excel-Datei die notwendigen Informationen zusammenbaut.

### Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.