Ejemplo n.º 1
0
        public static PdfPTable GetAllInfoTable()
        {
            PdfPTable table = new PdfPTable(4);

            table.WidthPercentage = 100f;
            table.SetWidths(new int[] { 1, 3, 2, 18 });

            PdfPCell cell;

            iTextSharp.text.Paragraph p;
            int rowNum       = 0;
            int textColumNum = 3;

            using (TextFieldParser parser = new TextFieldParser("../../Data/screen.csv", UTF8Encoding.UTF8, true))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    if (rowNum > 0)
                    {
                        for (int i = 0; i < textColumNum; i++)
                        {
                            p           = new iTextSharp.text.Paragraph(fields[i], new iTextSharp.text.Font(BF_Light, 10));
                            cell        = new PdfPCell(p);
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            table.AddCell(cell);
                        }

                        string fileName = string.Format("../../Data/{0}.csv", fields[1]);
                        float  yMax     = float.Parse(fields[3]);
                        float  yScale   = float.Parse(fields[4]);


                        cell = new PdfPCell(new Phrase(""));
                        cell.MinimumHeight = 55f;
                        cell.Border        = iTextSharp.text.Rectangle.NO_BORDER;
                        //画图的类,和cell关联
                        ResolutionChart chart = new ResolutionChart(fileName, yMax, yScale);
                        cell.CellEvent = chart;
                        table.AddCell(cell);
                        rowNum++;
                    }
                    else
                    {
                        rowNum++;
                    }
                }
            }


            return(table);
        }
Ejemplo n.º 2
0
        private PdfPTable GetAllInfoTable()
        {
            PdfPTable table = new PdfPTable(4);
            table.WidthPercentage = 100f;
            table.SetWidths(new int[] { 1, 3, 2, 18 });

            PdfPCell cell;
            Paragraph p;
            int rowNum = 0;
            int textColumNum = 3;

            using (TextFieldParser parser = new TextFieldParser("../../Data/screen.csv", UTF8Encoding.UTF8, true))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    if (rowNum > 0)
                    {
                        for (int i = 0; i < textColumNum; i++)
                        {
                            p = new Paragraph(fields[i], new Font(BF_Light, 10));
                            cell = new PdfPCell(p);
                            cell.Border = Rectangle.NO_BORDER;
                            table.AddCell(cell);
                        }

                        string fileName = string.Format("../../Data/{0}.csv", fields[1]);
                        float yMax = float.Parse(fields[3]);
                        float yScale = float.Parse(fields[4]);

                        cell = new PdfPCell(new Phrase(""));
                        cell.MinimumHeight = 55f;
                        cell.Border = Rectangle.NO_BORDER;
                        //画图的类,和cell关联
                        ResolutionChart chart = new ResolutionChart(fileName, yMax, yScale);
                        cell.CellEvent = chart;
                        table.AddCell (cell);
                        rowNum++;

                    }
                    else
                    {
                        rowNum++;
                    }
                }
            }

            return table;
        }