Hello,
Thanks for your inquiry.
For merge cells problem, we provide you some sample code, please try the code below. And you can refer to Grid demo in spire.pdf component. Please download Spire.PDF Pack Version:2.6( the download link is http://www.e-iceblue.com/Download/download-pdf-for-net-now/spirepdf-pack.html?Itemid=0) and install it in your computer. Please open Start menu->Programs->e-iceblue->Spire.PDF->Demos->CSDemos-VS2010, under WinForms/06_Grid/Grid-VS2010 project after finish the installing.
In Spire.PDF, Table is a special Grid. But it is more simple to use and especially to import data from DataSource. In Table, we cant manipulate the cell, we cant insert another table into one cell, but we can set the style by row. In Grid, we can manipulate each cell, set different style for every cell and embed another Grid.
If we miss something or you have other problem, please tell us.
- Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
PdfGrid grid = new PdfGrid();
grid.Columns.Add(5);
float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
for (int i = 0; i < grid.Columns.Count; i++)
{
grid.Columns[i].Width = width * 0.20f;
}
PdfGridRow row0 = grid.Rows.Add();
PdfGridRow row1 = grid.Rows.Add();
row0.Style.Font = new PdfTrueTypeFont(new Font("Arial",16f,FontStyle.Bold),true);
row1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Italic), true);
row0.Cells[0].Value = "Corporation";
row0.Cells[0].RowSpan = 2;
row0.Cells[1].Value = "B&K Undersea Photo";
row0.Cells[1].StringFormat=new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row0.Cells[1].ColumnSpan = 3;
row0.Cells[4].Value = "World";
row0.Cells[4].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold | FontStyle.Italic), true);
row0.Cells[4].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row0.Cells[4].Style.BackgroundBrush = PdfBrushes.LightGreen;
row1.Cells[1].Value = "Diving International Unlimited";
row1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row1.Cells[1].ColumnSpan = 4;
grid.Draw(page, new PointF(0, 0));
doc.SaveToFile("sample.pdf");
Best regards,
Amy
E-iceblue support team