title: how to generate dynamic columns in dynamicreports via java
body: <p>I wrote an app that gathers details about clients and generates a monthly report with Jasper Dynamic Report.
  until now , my report shows all fields, and some might be blank with some clients, and full in others.</p>
  
  <p>I want to make a dynamic report that chooses only the non empty columns for each client.
  to accomplish that I have created arrays for :</p>
  
  <p>aggregationSubtotalBuilder,
  TextColumnBuilder,
  ConditionalStyleBuilder,
  StyleBuilder,</p>
  
  <p>so instead of doing this</p>
  
  <pre><code>TextColumnBuilder&lt;Double&gt; offLine  = col.column "OffLine","offline",type.doubleType());
  TextColumnBuilder&lt;Double&gt; onLine   = col.column("OnLine","online",type.doubleType());
  </code></pre>
  
  <p>.
  .
  .</p>
  
  <p>im doing this:</p>
  
  <pre><code>for (int i = 0; i &lt; activeColumns.length; i++) 
    {
       activeColumnsForDataSource[i] = activeColumns[i];
       textColumnBuilder[i] = col.column("\"" + activeColumnsForDataSource[i] + "\"","\"" + activeColumns[i] + "\"",type.doubleType()).setTitleFixedHeight(30);
       conditionStyleBuilder[i] = stl.conditionalStyle(cnd.unEqual(textColumnBuilder[i], 0)).setFontSize(12).bold();
       styleBuilder[i] = stl.style().conditionalStyles(conditionStyleBuilder[i]).setBorder(stl.pen1Point());
  
       textColumnBuilder[i].setStyle(styleBuilder[i]).setHorizontalAlignment(HorizontalAlignment.CENTER);
       aggregationSubtotalBuilder[i] = sbt.sum(textColumnBuilder[i]).setLabel("סהכ" + activeColumns[i]).setLabelStyle(sumLabelStyle).setStyle(dataNameStyle);
  </code></pre>
  
  <p>where "activeColumns" is an array with the names of all active columns I want to add.</p>
  
  <p>one of the issues I have trouble with is that I have a Date column, that should always be displayed, and it is of a string type:</p>
  
  <pre><code>TextColumnBuilder&lt;String&gt; dayDate  = col.column("תאריך","date",type.stringType()).setStyle(rowNamesStyle);
  </code></pre>
  
  <p>so I cannot add it to the TextColumnBuilder Array .
  how can I add it to the report?</p>
  
  <p>in the build()
  if I do something like this</p>
  
  <pre><code>.columns(//add columns
               textColumnBuilder,dayDate)
         .columnGrid(
               textColumnBuilder,dayDate)
  </code></pre>
  
  <p>it will only show the last item I added , which is DayDate.</p>
  
  <p>what can I do ?</p>
  
  <p>Please help !</p>
  
  <p>thank you.</p>
  
  <p>dave.</p>