Ciao a tutti, spulciando alcuni esempi on line sono riuscito a visualizzare dei dati in una tabella all'interno di un PDF, ora però vorrei inserire, in fondo alla tabella, un totale con i valori di una colonna, come posso fare?
questo è il mio codice
int NumColumns = 12;
PdfPTable datatable = new PdfPTable(NumColumns);
datatable.HorizontalAlignment = Element.ALIGN_LEFT;
datatable.DefaultCell.Padding = 2;
float[] columnWidths = { 8, 13, 18, 15, 7, 10, 10, 10, 5, 16, 6, 6}; // percentage
datatable.SetWidths(columnWidths);
datatable.WidthPercentage = 100; // percentage
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
datatable.DefaultCell.BorderWidth = 1;
datatable.DefaultCell.GrayFill = 0.7f;
datatable.AddCell("Data");
datatable.AddCell("aaaa");
datatable.AddCell("vvv");
datatable.AddCell("bbb");
datatable.AddCell("5345");
datatable.AddCell("ert");
datatable.AddCell("erter");
datatable.AddCell("e3ter");
datatable.AddCell("dgdf");
datatable.HeaderRows = 1; // this is the end of the table header
for (int i = 0; i < tblaa.aa.Rows.Count; i++)
{
....
string[] row = { tblaa.aa[i].campo1.ToShortDateString(), tblaa.aa[i].campo2.ToString(), tblaa.aa[i].campo3.ToString(), tblaa.aa[i].campo4.ToString(), ....};
for (int x = 0; x <= 11; x++)
{
Phrase cell = new Phrase(row[x].ToString(), FontFactory.GetFont("Verdana", 8));
datatable.AddCell(cell);
}
}
document.Add(datatable);
Come posso aggiungere un totale ad una specifica colonna??
Grazie