Exemplo n.º 1
0
        public void DataManagerTest()
        {
            var dt = new DataTable();
            dt.Columns.Add("str1");
            dt.Columns.Add("str2");
            dt.Columns.Add("str3");
            var list = new List<MyClass>();
            DataManager manager = new DataManager(dt);

            Console.WriteLine();
        }
Exemplo n.º 2
0
        private void BuilBodyData(PdfPTable pdfPTable)
        {
            DataManager manager = new DataManager(table.DataSource) { NameIgnoreCase = true };

            int columns = table.Heads.Length;

            var indexs = new int[columns];
            for (int i = 0; i < columns; i++)
            {
                var col = table.Heads[i];
                indexs[i] = manager.GetOrdinal(col.BindName);
            }

            for (int i = 0; i < manager.Count; i++)
            {
                manager.Position = i;
                PdfPCell[] rowCells = new PdfPCell[columns];
                int j = 0;
                foreach (var i1 in indexs)
                {
                    var cel = ObjectUtility.Cast<string>(manager.GetValue(i1));

                    rowCells[j] = new PdfPCell((new Phrase(string.IsNullOrEmpty(cel) ? " " : cel, PDFBuilder.DefaultFont)))
                    {
                        PaddingLeft = 4,
                        PaddingRight = 4,
                        UseBorderPadding = true
                    };
                    j++;
                }

                pdfPTable.Rows.Add(new PdfPRow(rowCells));
                pdfPTable.CompleteRow();
            }
            if (!table.FillRows) return;
            var count = table.FillRowCounts - manager.Count;
            if (count > 0)
            {
                FillTabel(count, pdfPTable);
            }
        }