iTextSharp.text.Table.AddCell C# (CSharp) Method

AddCell() public method

Adds a Cell to the Table at a certain row and column.
public AddCell ( Cell aCell, int row, int column ) : void
aCell Cell The Cell to add
row int The row where the Cell will be added
column int The column where the Cell will be added
return void
        public void AddCell(Cell aCell, int row, int column) {
            AddCell(aCell, new System.Drawing.Point(row,column));
        }

Same methods

Table::AddCell ( Cell cell ) : 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
ファイル: WebForm1.aspx.cs プロジェクト: wjkong/MicNets
        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