网格视图到具有动态行的PDF [英] Grid View To PDF having dynamics rows

查看:57
本文介绍了网格视图到具有动态行的PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图,其中在行数据绑定事件中动态添加行,而其余行则从oracle数据库中检索.单元格也合并在gridview中.我想将整个网格转换为PDF,因为它出现在网格内.通过使用itextsharp库,网格被转换为PDF,但是单元格合并和动态行不可见.请告诉我解决方案

I am having grid view in which rows are added dynamically at row databound event and rest are retrieved from oracle database. The cells are also merged in the gridview. I want to convert the whole grid into PDF as it is appearing inside the grid. By using itextsharp library grid is converted into PDF but cell merging and dynamic rows are not visible. Kindly tell me the solution

推荐答案

您可以在代码隐藏中生成表,并遍历gridview行并添加它.

You can generate table in your codebehind and iterate through gridview rows and add it.

  iTextSharp.text.Table schedule = new iTextSharp.text.Table(6, 6);
            schedule.BorderWidth = 1;

            schedule.Padding = 1;
            schedule.Spacing = 1;

            schedule.Width = 100;
            schedule.DefaultCell.SetHorizontalAlignment("center");
            //set table header
            schedule.AddCell(new Cell(new Chunk("Course", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
            schedule.AddCell(new Cell(new Chunk("Duration: Start", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
            schedule.AddCell(new Cell(new Chunk("Duration: Finish", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
            schedule.AddCell(new Cell(new Chunk("Instalment No", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
            schedule.AddCell(new Cell(new Chunk("Instalment Cost", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
            schedule.AddCell(new Cell(new Chunk("Payment Due Date", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));

//Add data.

foreach (GridViewRow row in grdView.Rows)
{
 schedule.AddCell(new Cell(new Chunk(row.Cells[0].Text, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))));
...
...
...

}


这篇关于网格视图到具有动态行的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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