iTextSharp.text.Table.AddCell C# (CSharp) Метод

AddCell() публичный Метод

Adds a Cell to the Table.
public AddCell ( Cell cell ) : void
cell Cell a Cell
Результат void
        public void AddCell(Cell cell) {
            try {
                AddCell(cell, curPosition);
            }
            catch (BadElementException) {
                // don't add the cell
            }
        }

Same methods

Table::AddCell ( Cell aCell, int row, int column ) : void
Table::AddCell ( Cell aCell, object aLocation ) : void
Table::AddCell ( Phrase content ) : void
Table::AddCell ( Phrase content, System location ) : void
Table::AddCell ( string content ) : void
Table::AddCell ( string content, System location ) : void

Usage Example

Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Page.Title = "Contact List";
            MemoryStream PDFData = new MemoryStream();

            // step 1: creation of a document-object
            Document document = new Document();

            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file

            PdfWriter.GetInstance(document, PDFData);

            // step 3: we open the document
            document.Open();

            // step 4: we add a paragraph to the document
            document.Add(new Paragraph(DateTime.Now.ToString()));
            Contact oContact = new Contact();
            DataTable dtContact = oContact.LoadAll();
            int numRow = dtContact.Rows.Count;
            int numCol = 5;
            iTextSharp.text.Table aTable = new iTextSharp.text.Table(numCol, numRow);
            aTable.AutoFillEmptyCells = true;
            aTable.Padding = 1;
            aTable.Spacing = 1;

            Cell cell = new Cell(new Phrase("Contact List", FontFactory.GetFont(FontFactory.TIMES, 14, Font.BOLD)));
            cell.Header = true;
            cell.Colspan = numCol;
            cell.BackgroundColor = Color.LIGHT_GRAY;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;

            aTable.AddCell(cell);

            for (int i = 0; i < dtContact.Rows.Count; i++)
            {
                for (int n = 1; n <= numCol; n++)
                    aTable.AddCell(dtContact.Rows[i][n].ToString());

            }
            document.Add(aTable);
            // step 5: we close the document
            document.Close();

            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.Charset = string.Empty;
            Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
            Response.AddHeader("Content-Disposition",
                "attachment; filename=" + Title.Replace(" ", "").Replace(":", "-") + ".pdf");

            Response.OutputStream.Write(PDFData.GetBuffer(), 0, PDFData.GetBuffer().Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.End();
        }
All Usage Examples Of iTextSharp.text.Table::AddCell