当前位置: 首页>>代码示例>>C#>>正文


C# Table.SetWidths方法代码示例

本文整理汇总了C#中iTextSharp.text.Table.SetWidths方法的典型用法代码示例。如果您正苦于以下问题:C# Table.SetWidths方法的具体用法?C# Table.SetWidths怎么用?C# Table.SetWidths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.Table的用法示例。


在下文中一共展示了Table.SetWidths方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateCoreReport

    public iTextSharp.text.Table GenerateCoreReport(String RptDate)
    {
        iTextSharp.text.Table datatable = new iTextSharp.text.Table(10);
        datatable.Padding = 4.0F;
        datatable.Spacing = 0.0F;
        //datatable.setBorder(Rectangle.NO_BORDER);
        int[] headerwidths = { 10, 24, 12, 12, 7, 7, 7, 7, 1, 1 };

        datatable.SetWidths(headerwidths);
        datatable.Width = 100;

        // the first cell spans 10 columns
        Cell cell = new Cell(new Phrase("Daily Production Report For " + RptDate, FontFactory.GetFont(FontFactory.HELVETICA, 18, iTextSharp.text.Font.BOLD)));
        cell.HorizontalAlignment = 1;
        cell.Leading = 30;
        cell.Colspan = 10;
        cell.Border =   iTextSharp.text.Rectangle.NO_BORDER;
        cell.BackgroundColor = iTextSharp.text.Color.LIGHT_GRAY;
        datatable.AddCell(cell);

        // These cells span 2 rows
        datatable.DefaultCellBorderWidth = 2;
        datatable.DefaultHorizontalAlignment = 1;
        datatable.DefaultRowspan = 2;
        datatable.AddCell("User Id");
        datatable.AddCell(new Phrase("Name", FontFactory.GetFont(FontFactory.HELVETICA, 14, iTextSharp.text.Font.BOLD)));
        datatable.AddCell("Work order");
        datatable.AddCell("Comments");

        // This cell spans the remaining 6 columns in 1 row
        datatable.DefaultRowspan = 1;
        datatable.DefaultColspan = 6;
        datatable.AddCell("Hours");

        // These cells span 1 row and 1 column
        datatable.DefaultColspan = 1;
        datatable.AddCell("Fab.");
        datatable.AddCell("Finish");
        datatable.AddCell("Eng.");
        datatable.AddCell("Misc.");
        datatable.AddCell("");
        datatable.AddCell("");

        //Here goes the Outer Loop to get the Project Information for the Day.Get the Project Name and display Here.
        whitfield_prod_reports _wproj = new whitfield_prod_reports();
        DataSet _mOuter = _wproj.GetProjectReportOuter(RptDate);
        DataTable dtProject = _mOuter.Tables[0];
        foreach (DataRow dProjRow in dtProject.Rows)
        {
            String _projNumber = dProjRow["TWC_Proj_Number"] == DBNull.Value ? "" : dProjRow["TWC_Proj_Number"].ToString();
            String _projName = dProjRow["ProjName"] == DBNull.Value ? "" : dProjRow["ProjName"].ToString();
            String _rptNumber = dProjRow["twc_report_number"] == DBNull.Value ? "" : dProjRow["twc_report_number"].ToString();

            Cell cell1 = new Cell(new Phrase(_projName + '(' + _projNumber + ')' , FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.BOLD)));
            cell1.HorizontalAlignment = 1;
            cell1.Leading = 30;
            cell1.Colspan = 10;
            cell1.Border = iTextSharp.text.Rectangle.TOP_BORDER;
            cell1.BackgroundColor = iTextSharp.text.Color.LIGHT_GRAY;
            datatable.AddCell(cell1);

            datatable.DefaultCellBorderWidth = 1;
            datatable.DefaultRowspan = 1;

            //Here Goes the Inner Loop for the Employees worked on the Project.
            DataSet _mInner = _wproj.GetProjectReportInner(Convert.ToInt32(_rptNumber), Convert.ToInt32(_projNumber));
            DataTable dtActivity = _mInner.Tables[0];
            foreach (DataRow drActivity in dtActivity.Rows)
            {
                datatable.DefaultHorizontalAlignment = 1;
                datatable.AddCell(drActivity["loginid"] == DBNull.Value ? "" : drActivity["loginid"].ToString());
                datatable.AddCell(drActivity["UName"] == DBNull.Value ? "" : drActivity["UName"].ToString());
                datatable.AddCell(drActivity["Description"] == DBNull.Value ? "" : drActivity["Description"].ToString());
                datatable.AddCell(drActivity["empl_comments"] == DBNull.Value ? "" : drActivity["empl_comments"].ToString());
                datatable.DefaultHorizontalAlignment = 0;
                datatable.AddCell(drActivity["fab_hours"] == DBNull.Value ? "0" : drActivity["fab_hours"].ToString());
                datatable.AddCell(drActivity["fin_hours"] == DBNull.Value ? "0" : drActivity["fin_hours"].ToString());
                datatable.AddCell(drActivity["eng_hours"] == DBNull.Value ? "0" : drActivity["eng_hours"].ToString());
                datatable.AddCell(drActivity["misc_hours"] == DBNull.Value ? "0" : drActivity["misc_hours"].ToString());
                _totFabHours += Convert.ToInt32(drActivity["fab_hours"] == DBNull.Value ? "0" : drActivity["fab_hours"].ToString());
                _totFinHours += Convert.ToInt32(drActivity["fin_hours"] == DBNull.Value ? "0" : drActivity["fin_hours"].ToString());
                _totEngHours += Convert.ToInt32(drActivity["eng_hours"] == DBNull.Value ? "0" : drActivity["eng_hours"].ToString());
                _totMiscHours += Convert.ToInt32(drActivity["misc_hours"] == DBNull.Value ? "0" : drActivity["misc_hours"].ToString());
                datatable.AddCell("");
                datatable.AddCell("");
            }
                    //Here goes the SubTotal Per project.. Dont Forget.
                    datatable.DefaultCellBorderWidth = 1;
                    datatable.DefaultRowspan = 1;
                    datatable.DefaultHorizontalAlignment = 1;
                    datatable.AddCell("");
                    datatable.AddCell("Subtotal:");
                    datatable.AddCell("");
                    datatable.AddCell("");
                    datatable.DefaultHorizontalAlignment = 0;
                    datatable.AddCell(_totFabHours.ToString());
                    datatable.AddCell(_totFinHours.ToString());
                    datatable.AddCell(_totEngHours.ToString());
                    datatable.AddCell(_totMiscHours.ToString());
                    datatable.AddCell("");
//.........这里部分代码省略.........
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:101,代码来源:msir_render_pdf.aspx.cs

示例2: Export

        //public void PDModel2Html(PDModel m)
        //{
        //    Export(m, ExportTyep.HTML);
        //}

        private void Export(IList<PDTable> tableList,string title, ExportTyep exportType)
        {
            Document doc = new Document(PageSize.A4.Rotate(), 20, 20, 20, 20);
            DocWriter w;

            switch (exportType)
            {
                case ExportTyep.PDF:
                    w = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                    break;
                case ExportTyep.RTF:
                    w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                    break;
                //case ExportTyep.HTML:
                //    w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                //break;
                default:
                    break;
            }

            doc.Open();
            doc.NewPage();

            //IList<PDTable> tableList = m.AllTableList;

            //Chapter cpt = new Chapter(m.Name, 1);
            Chapter cpt = new Chapter(title, 1);
            Section sec;

            //doc.AddTitle(m.Name);
            doc.AddTitle(title);
            doc.AddAuthor("Kalman");
            doc.AddCreationDate();
            doc.AddCreator("Kalman");
            doc.AddSubject("PDM数据库文档");

            foreach (PDTable table in tableList)
            {
                sec = cpt.AddSection(new Paragraph(string.Format("{0}[{1}]", table.Name, table.Code), font));

                if (string.IsNullOrEmpty(table.Comment) == false)
                {
                    Chunk chunk = new Chunk(table.Comment, font);
                    sec.Add(chunk);
                }

                t = new Table(9, table.ColumnList.Count);

                //t.Border = 15;
                //t.BorderColor = Color.BLACK;
                //t.BorderWidth = 1.0f;
                t.AutoFillEmptyCells = true;
                t.CellsFitPage = true;
                t.TableFitsPage = true;
                t.Cellpadding = 3;
                //if (exportType == ExportTyep.PDF) t.Cellspacing = 2;
                t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE;

                t.SetWidths(new int[] { 200, 200, 150, 50, 50, 50, 50, 50, 300 });

                t.AddCell(BuildHeaderCell("名称"));
                t.AddCell(BuildHeaderCell("代码"));
                t.AddCell(BuildHeaderCell("数据类型"));
                t.AddCell(BuildHeaderCell("长度"));
                t.AddCell(BuildHeaderCell("精度"));
                t.AddCell(BuildHeaderCell("主键"));
                t.AddCell(BuildHeaderCell("外键"));
                t.AddCell(BuildHeaderCell("可空"));
                t.AddCell(BuildHeaderCell("注释"));

                foreach (PDColumn column in table.ColumnList)
                {
                    t.AddCell(BuildCell(column.Name));
                    t.AddCell(BuildCell(column.Code));
                    t.AddCell(BuildCell(column.DataType));
                    t.AddCell(BuildCell(column.Length == 0 ? "" : column.Length.ToString()));
                    t.AddCell(BuildCell(column.Precision == 0 ? "" : column.Precision.ToString()));
                    t.AddCell(BuildCell(column.IsPK ? " √" : ""));
                    t.AddCell(BuildCell(column.IsFK ? " √" : ""));
                    t.AddCell(BuildCell(column.Mandatory ? "" : " √"));
                    t.AddCell(BuildCell(column.Comment));
                }

                sec.Add(t);
            }

            doc.Add(cpt);
            doc.Close();
        }
开发者ID:Leafney,项目名称:Kalman.Studio,代码行数:94,代码来源:Export.cs

示例3: WriteFields


//.........这里部分代码省略.........
                        for (int i = 0; i < firstRow.Count; i++)
                        {
                            int widthPercent = Convert.ToInt32(Math.Truncate((UnitConversion.GetPdfLetterWidth(firstRow[i].Width, sysFont)
                                / Convert.ToDouble((this.pdfDoc.PageSize.Width - this.pdfDoc.LeftMargin - this.pdfDoc.RightMargin))) * 100)); //算出百分比

                            if (i == 0)
                            {
                                widths[i] = widthPercent;

                                if (firstRow[i].Cells > 1)
                                {
                                    for (int j = 0; j < firstRow[i].Cells - 1; j++)
                                    {
                                        widths[i + j + 1] = widthPercent;
                                    }
                                }
                            }
                            else
                            {
                                widths[previousFieldCells] = widthPercent;

                                if (firstRow[i].Cells > 1)
                                {
                                    for (int j = 0; j < firstRow[i].Cells - 1; j++)
                                    {
                                        widths[previousFieldCells + j + 1] = widthPercent;
                                    }
                                }
                            }

                            previousFieldCells += firstRow[i].Cells;
                        }

                        tb.SetWidths(widths);

                        previousFieldCells = 0;
                    }
                    #endregion

                    if (!this.report.Format.ColumnGridLine)
                    {
                        tb.Border = Rectangle.NO_BORDER;
                    }

                    tb.Cellpadding = PdfSizeConfig.Cellpadding;
                    //tb.Width = ((this.pdfDoc.PageSize.Width - this.pdfDoc.LeftMargin - this.pdfDoc.RightMargin) / this.pdfDoc.PageSize.Width) * 100; //此處為百分比
                    tb.Width = 100;
                    tb.Alignment = Element.ALIGN_LEFT;

                    for (int j = startIndex[l]; j < list.Count; j++)
                    {
                        if (startIndex.Count != 1)
                        {
                            if (l != startIndex.Count - 1 && j == startIndex[l + 1])
                            {
                                break;
                            }
                        }

                        List<PdfDesc> row = list[j];

                        previousFieldCells = 0;
                        for (int i = 0; i < row.Count; i++)
                        {
                            PdfDesc pdfDesc = row[i];
开发者ID:san90279,项目名称:UK_OAS,代码行数:66,代码来源:PdfController.cs


注:本文中的iTextSharp.text.Table.SetWidths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。