menu

Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfGridCell - Xamarin.Android API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfGridCell

    Represents the schema of a cell in a PdfGrid.

    Inheritance
    System.Object
    PdfGridCell
    Namespace: Syncfusion.Pdf.Grid
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfGridCell : Object
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set cell style.
    cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set cell style.
    cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    Constructors

    PdfGridCell()

    Initializes a new instance of the PdfGridCell class.

    Declaration
    public PdfGridCell()
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set cell style.
    cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set cell style.
    cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    PdfGridCell(PdfGridRow)

    Initializes a new instance of the PdfGridCell class with the row.

    Declaration
    public PdfGridCell(PdfGridRow row)
    Parameters
    Type Name Description
    PdfGridRow row

    The row of the cell.

    Properties

    ColumnSpan

    Gets or sets a value that indicates the total number of columns that cell spans within a PdfGrid.

    Declaration
    public int ColumnSpan { get; set; }
    Property Value
    Type Description
    System.Int32

    The number of columns that cell should span. The default value is 1.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    Height

    Gets the height of the PdfGrid cell.[Read-Only]

    Declaration
    public float Height { get; }
    Property Value
    Type Description
    System.Single

    The height.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set cell style.
    cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
    //Get cell width.
    float cellWidth = cell.Width;
    //Get cell height.
    float cellHeight = cell.Height;
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set cell style.
    cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
    'Get cell width.
    Dim cellWidth As Single = cell.Width
    'Get cell height.
    Dim cellHeight As Single = cell.Height
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    ImagePosition

    Gets or sets the image alignment type of the PdfGridCell background image.

    Declaration
    public PdfGridImagePosition ImagePosition { get; set; }
    Property Value
    Type
    PdfGridImagePosition
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    IsHtmlText

    Gets or sets the cell content is HTML text or not

    Declaration
    public bool IsHtmlText { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    PdfTag

    Get or set the tag for the element

    Declaration
    public PdfTag PdfTag { get; set; }
    Property Value
    Type
    PdfTag
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    RowSpan

    Gets or sets a value that indicates the total number of rows that cell spans within a PdfGrid.

    Declaration
    public int RowSpan { get; set; }
    Property Value
    Type Description
    System.Int32

    The number of rows that cell should span. The default value is 1.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    StringFormat

    Gets or sets the string format.

    Declaration
    public PdfStringFormat StringFormat { get; set; }
    Property Value
    Type Description
    PdfStringFormat

    The string format.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    Style

    Gets or sets the cell style.

    Declaration
    public PdfGridCellStyle Style { get; set; }
    Property Value
    Type Description
    PdfGridCellStyle

    Represents the style information applied to individual cells within a PdfGrid.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    Value

    Gets or sets the value of the cell.

    Declaration
    public object Value { get; set; }
    Property Value
    Type Description
    System.Object

    Value can be string or PdfGrid, PdfGrid will create a nested grid.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;            
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set row span
    cell.RowSpan = 2;
    //set column span.
    cell.ColumnSpan = 2;
    //Check whether the text is HTML text?
    bool isHtmlText = cell.IsHtmlText;
    //Set Value.
    cell.Value = "George";
    //Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center;
    //Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit;
    //Set PDF tag.
    cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
    //Set cell style.                 
    cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set row span
    cell.RowSpan = 2;
    'set column span.
    cell.ColumnSpan = 2;
    'Check whether the text is HTML text?
    Dim isHtmlText As Boolean = cell.IsHtmlText
    'Set Value.
    cell.Value = "George"
    'Set string format.
    cell.StringFormat.Alignment = PdfTextAlignment.Center
    'Set image position.
    cell.ImagePosition = PdfGridImagePosition.Fit
    'Set PDF tag.
    cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
    'Set cell style.                 
    cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)

    Width

    Gets the width of the PdfGrid cell.[Read-Only]

    Declaration
    public float Width { get; }
    Property Value
    Type Description
    System.Single

    The width of the cell which is set by the column width.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page.
    PdfPage page = doc.Pages.Add();
    //Create a PdfGrid.
    PdfGrid pdfGrid = new PdfGrid();
    //Create a DataTable.
    DataTable dataTable = new DataTable("EmpDetails");
    //Add columns to the DataTable           
    dataTable.Columns.Add("ID");
    dataTable.Columns.Add("Name");
    //Add rows to the DataTable.
    dataTable.Rows.Add(new object[] { "E01", "Clay" });
    dataTable.Rows.Add(new object[] { "E02", "Thomas" });
    //Assign data source.
    pdfGrid.DataSource = dataTable;
    //PDF grid cell
    PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
    //Set cell style.
    cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
    //Get cell width.
    float cellWidth = cell.Width;
    //Get cell height.
    float cellHeight = cell.Height;
    //Draw grid to the page of PDF document.
    pdfGrid.Draw(page, new PointF(10, 10));
    //Save the document.
    doc.Save("Output.pdf");
    //close the document
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page.
    Dim page As PdfPage = doc.Pages.Add()
    'Create a PdfGrid.
    Dim pdfGrid As New PdfGrid()
    'Create a DataTable.
    Dim dataTable As New DataTable("EmpDetails")
    'Add columns to the DataTable           
    dataTable.Columns.Add("ID")
    dataTable.Columns.Add("Name")
    'Add rows to the DataTable.
    dataTable.Rows.Add(New Object() { "E01", "Clay"})
    dataTable.Rows.Add(New Object() { "E02", "Thomas"})
    'Assign data source.
    pdfGrid.DataSource = dataTable
    'PDF grid cell
    Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
    'Set cell style.
    cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
    'Get cell width.
    Dim cellWidth As Single = cell.Width
    'Get cell height.
    Dim cellHeight As Single = cell.Height
    'Draw grid to the page of PDF document.
    pdfGrid.Draw(page, New PointF(10, 10))
    'Save the document.
    doc.Save("Output.pdf")
    'close the document
    doc.Close(True)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved