I want to a summary of orders group by order date and subtotal and grand total for the records.
Output would be
Sales
From 11 Nov 2011 to 13 Nov 2011
Date:11 Nov 2011
SR# ITEM_NAME Quantity
1 Pizza 2
2 Cold Drink 2
total orders=2
Date:12 Nov 2011
3 Pizza 2
4 Cold Drink 6
5 Pizza 7
6 Cold Drink 3
total orders=4
Date:13 Nov 2011
7 Pizza 2
8 Cold Drink 6
9 Pizza 7
total orders=3
Plz note that one first row of the result is header row. How can i do that? Should i make two templates.
i.e one containing bookmarks and the other containing a data table. I have to use table for records. and bookmarks for the date. Any idea? should do that programticaly?
code so far:
Document doc = new Document("D:\\Templates\\MyTemplate.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// We call this method to start building the table.
builder.startTable();
ResultSetMetaData metaData = rs.getMetaData();
// header row for columns header
System.out.println(metaData.getColumnCount());
int rowCount = 1;
for (int j = 1; j < 2; j++)
{
System.out.println("Header Row" + rowCount);
for (int i = 1; i <= metaData.getColumnCount(); i++)
{
builder.insertCell();
builder.write(metaData.getColumnName(i));
System.out.print(" - " + metaData.getColumnName(i));
}
builder.endRow();
}
System.out.println();
// columns values
while (rs.next())
{
rowCount++;
System.out.println("Row Started" + rowCount);
for (int i = 1; i <= metaData.getColumnCount(); i++)
{
builder.insertCell();
builder.write(rs.getObject(i).toString());
System.out.print("----" + i);
}
System.out.println("Row Ended" + rowCount);
builder.endRow();
}
// Signal that we have finished building the table.
builder.endTable();
// Save the document to disk.
doc.save("D:\\templates\\MyTemplate.doc");
rs.close();