Click here to Skip to main content
15,887,356 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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

C#
  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))));
...
...
...

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900