- Code: Select all
Color borderColor = Color.FromArgb(75, 172, 198);
String outputFile = "output.pdf";
PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, new PdfMargins(10, 10, 10, 10));
PdfTrueTypeFont font3 = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Bold), true);
PdfStringFormat format3 = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
PdfGrid grid8 = null;
PdfGrid grid9 = null;
PdfGridRow pdfGridRow8;
PdfGridRow pdfGridRow9;
grid8 = new PdfGrid();
grid8.AllowCrossPages = true;
grid8.Style.CellSpacing = 3f;
grid8.Columns.Add(6);
grid8.Columns[0].Width = 40;
grid8.Columns[1].Width = 40;
grid8.Columns[2].Width = 180;
grid8.Columns[3].Width = 60;
grid8.Columns[4].Width = 60;
grid8.Columns[5].Width = 190;
pdfGridRow8 = grid8.Headers.Add(2)[0];
pdfGridRow9 = grid8.Headers[1];
pdfGridRow8.Height = 20;
String[] header8 = { "Item #", "Qty", "Disposition", "Responsibility/Expense", "", "Comments/Instructions" };
String[] header9 = { "", "", "", "Kavlico", "Supplier", "" };
for (i = 0; i < header8.Length; i++)
{
PdfGridCell cell = pdfGridRow8.Cells[i];
if (i != 4)
{
if ((i == 0) || (i == 1))
cell.RowSpan = 2;
else
cell.RowSpan = 1;
if (i == 3)
cell.ColumnSpan = 2;
else
cell.ColumnSpan = 1;
cell.Value = header8[i];
cell.Style.Font = font3;
cell.Style.Borders = borders;
cell.StringFormat = format3;
}
}
for (i = 0; i < header9.Length; i++)
{
PdfGridCell cell = pdfGridRow9.Cells[i];
if ((i == 3) || (i == 4))
{
cell.Value = header9[i];
cell.Style.Font = font3;
cell.Style.Borders = borders;
cell.StringFormat = format3;
}
}
grid8.Draw(page, new Point(0, 435));
pdf.SaveToFile(outputFile, FileFormat.PDF);
pdf.Close();
3) Version - Spire.Pdf for .NET v4.0.30319
4) OS - Windows 11 64-bit
5) App Type - WinForm 4.7.2
First two columns (0,1) have rowspan=2, colspan=1
Column 2 has rowspan=1, colspan=1
Column 3 has rowspan=1, colspan=2
Column 4 was rowspanned so it should not show up on column4
Column 5 has rowspan=1, colspan=1
I get the output in the attachment, instead of what I thought I asked for above.