iTextSharp的,细胞不是由行的长度可分割的数 [英] ItextSharp, number of Cells not dividable by the length of the row

查看:209
本文介绍了iTextSharp的,细胞不是由行的长度可分割的数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇文章在这里如此忍受我。



我目前工作的需要我做一个动态表C#项目。 (该程序可以决定一排多少个单元中包含的用户。)



我已经想通了,但在这里,这一点问题来了。说,例如用户想要在3行中显示的数据,但有5事情需要显示它将只显示前3和最后2消失。



我怎样才能使它这样,如果细胞数不能由行(例如4个细胞用2行3或5单元的行),该空单元格中加入这样的最后一行的长度被划分?也显示(或显示的最后一行,其中所述细胞是不足以填满该行的任何其它固定)



实施例的代码:

  PdfPTable卡=新PdfPTable(3); 

card.AddCell(行1小区1);
card.AddCell(行1小区2);
card.AddCell(行1小区3);
card.AddCell(行2小区1);
card.AddCell(行2小区2);
card.AddCell(行2单元3);
card.AddCell(行3单元1未显示);
card.AddCell(行3单元2未显示);

doc.Add(卡);


解决方案

有一个关于 PdfPTable的方法所谓的 =nofollow的> CompleteRow ,做你所谈论的到底是什么。只是把它当你用表完成并表的默认的单元格,将填补空白。


This is my first post here so bear with me.

I am currently working on a C# project which requires me to make a Dynamic Table. (The user of the program can decide how many Cells a row contains.)

That bit I have figured out, but here comes the problem. Say for example the user wants the data displayed in rows of 3 but there are 5 things that need to be displayed it will only show the first 3 and the last 2 disappear.

How can I make it so that if the number of cells can't be divided by the length of the row (like 4 cells with rows of 3 or 5 cells with rows of 2) that an empty cell is added so the last row is also displayed (or any other fix that displays the last row where the cells are not enough to fill that row)?

Example code:

        PdfPTable card = new PdfPTable(3);

        card.AddCell("Row 1 cell 1");
        card.AddCell("Row 1 cell 2");
        card.AddCell("Row 1 cell 3");
        card.AddCell("Row 2 cell 1");
        card.AddCell("Row 2 cell 2");
        card.AddCell("Row 2 cell 3");
        card.AddCell("Row 3 cell 1 Not showing");
        card.AddCell("Row 3 cell 2 Not showing");

        doc.Add(card);

解决方案

There's a method on PdfPTable called CompleteRow that does exactly what you are talking about. Just call it when you are done with the table and it will "fill in the blanks" with the table's "default cell".

这篇关于iTextSharp的,细胞不是由行的长度可分割的数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆