views:

386

answers:

1

Hi, i have some problems with rowspan:

var doc1 = new Document();
        doc1.SetPageSize(PageSize.A4.Rotate());
        string path = Server.MapPath("PDFs");
        PdfWriter.GetInstance(doc1, new FileStream(path + "/Doc1.pdf", FileMode.Create));
        doc1.Open();
        PdfPTable table = new PdfPTable(17);
        PdfPCell cell = new PdfPCell(new Phrase("Missioni aggregato per macro causali"));
        cell.Colspan = 17;
        cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
        table.AddCell(cell);
        cell = new PdfPCell(new Phrase("Matricola"));
        cell.Rowspan = 2;
        cell.Rotation = 90;
        table.AddCell(cell);

        cell = new PdfPCell(new Phrase("Nominativo"));
        cell.Rowspan = 2;
        table.AddCell(cell);

        cell = new PdfPCell(new Phrase("Assegnazione"));            
        cell.Colspan = 2;
        table.AddCell(cell);            

        cell = new PdfPCell(new Phrase("Riepilogo missioni valori dal "));
        cell.Colspan = 13;
        cell.Rowspan = 2; 
        table.AddCell(cell);

        cell = new PdfPCell(new Phrase("Struttura"));            
        table.AddCell(cell);

        cell = new PdfPCell(new Phrase("Ufficio"));
        table.AddCell(cell);

the cell "Riepilogo missioni valori dal " is in the same row of cell "struttura" and cell "ufficio" Why?

how can i do?

thanks

+1  A: 

Your cell "Riepilogo missioni valori dal " only spans 13 columns. PdfPTable requires that you fill in the rest of those columns (4) at the end of your current row before it will jump to the next row of 17 columns.

To fill in the end of your row, you can either add 4 empty cells or use the CompleteRow method.

table.AddCell("")
table.AddCell("")
table.AddCell("")
table.AddCell("")

or

table.CompleteRow()
Stewbob