iTextSharp,PdfPTable,如何设置表的列数和每列的相对宽度?

iamhelen 2014-09-02 04:06:59
private PdfPCell MakeCell(string strData, byte iCol)
{
iTextSharp.text.Font CellFont = iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
PdfPCell cell = new PdfPCell();
cell.Colspan = iCol;
Paragraph parag = new Paragraph(strData, CellFont);
cell.AddElement(parag);
return cell;
}
PdfPTable table = new PdfPTable(4); //这个4不是代表有4列吗???
table.AddCell(MakeCell("No.", 1));
table.AddCell(MakeCell("Mode", 2));
table.AddCell(MakeCell("OBIS", 3));
table.AddCell(MakeCell("Description", 4));
//table.SetWidths(new int[] { 10, 20, 20, 50 });
为何只有3列,Description这列到了第2行?这是啥原因?
当new PdfPTable(5);new PdfPTable(6);都只有3列,当new PdfPTable(7);new PdfPTable(8);new PdfPTable(9);new PdfPTable(10);有4列了,为何会这样?

敬请各位老师指点!谢谢!
...全文
425 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧