【问题标题】:itextsharp: rowspan doesn't workitextsharp:行跨度不起作用
【发布时间】:2011-01-23 06:12:48
【问题描述】:

我对行跨度有一些问题:

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);

单元格“Riepilogomissioni valori dal”在单元格“struttura”和单元格“ufficio”的同一行中 为什么?

我该怎么办?

谢谢

【问题讨论】:

  • 我在 iTextSharp 7 上对其进行了测试,它可以工作

标签: itextsharp html-table


【解决方案1】:

您的单元格“Riepilogomissioni valori dal”仅跨越 13 列。 PdfPTable 要求您在当前行的末尾填写其余的列 (4),然后它才会跳转到下一行的 17 列。

要填写行尾,您可以添加 4 个空单元格或使用 CompleteRow 方法。

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

table.CompleteRow()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-23
    • 1970-01-01
    • 2016-10-23
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多