Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Calendar;
- import java.util.Date;
- import org.pentaho.reporting.engine.classic.core.util.TypedTableModel;
- //This creates the table model that will be passed to the report.
- String[] columnNames = ["Date Value"];
- Class[] columnTypes = [Date.class];
- def myTable = new TypedTableModel(columnNames, columnTypes);
- //This grabs the start date from the report
- def startDate = dataRow.get("start_date");
- //whenever you use dataRow, always follow it up with a check for null
- if (startDate == null)
- //If null, return a blank table.
- return myTable;
- //Create a calendar, it is easier to manipulate than the Date class.
- def cal = Calendar.getInstance();
- //Set the calendar to whatever is in our start date.
- cal.setTime(startDate);
- for(int i = 0; i < 5; i++) {
- //This adds seven days to the calendar
- cal.add(Calendar.DAY_OF_MONTH, 7);
- //This creates a new insertable object from our calendar
- Object [] insertValue = [cal.getTime()];
- //This inserts the insertable object into the table model.
- myTable.addRow(insertValue);
- }
- //send the table model back to the report.
- return myTable;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement