コード例 #1
1
ファイル: VersenyEredmenyLap.cs プロジェクト: belinyak/Ijasz2
        private static void TablazatFormazas( Table table ) {
            table.AutoFit = AutoFit.Contents;
            table.AutoFit = AutoFit.ColumnWidth;
            foreach( Row row in table.Rows ) {
                row.Cells[0].Width = 30;
                row.Cells[1].Width = 50;
                row.Cells[2].Width = 50;
                row.Cells[3].Width = 200;
                row.Cells[4].Width = 200;
                row.Cells[5].Width = 70;
                row.Cells[6].Width = 70;
            }

            Border c = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black);
            Border d = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.five, 0, Color.Black);
            table.SetBorder( TableBorderType.InsideH, d );
            table.SetBorder( TableBorderType.InsideV, c );
            table.SetBorder( TableBorderType.Bottom, c );
            table.SetBorder( TableBorderType.Top, c );
            table.SetBorder( TableBorderType.Left, c );
            table.SetBorder( TableBorderType.Right, c );

        }
コード例 #2
0
ファイル: Beirolap.cs プロジェクト: belinyak/Ijasz2
        private void AlairasTablazat( ) {
            document.AddFooters( );
            var footer = document.Footers.odd;
            var table = footer.InsertTable(3, 2);
            table.Alignment = Alignment.center;
            table.AutoFit = AutoFit.ColumnWidth;
            foreach( var row in table.Rows ) {
                row.Cells[0].Width = 150;
                row.Cells[1].Width = 150;
                row.Cells[0].Paragraphs[0].Alignment = Alignment.center;
                row.Cells[1].Paragraphs[0].Alignment = Alignment.center;
            }
            table.Rows[1].Height = 25;
            table.Rows[1].Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
            table.Rows[1].Cells[1].VerticalAlignment = VerticalAlignment.Bottom;

            const string pontok = "...................................";
            const string beiroAlairas = "Beíró aláírása";
            const string induloAlairas = "Versenyző aláírása";

            table.Rows[0].Cells[0].Paragraphs[0].Append( pontok );
            table.Rows[0].Cells[1].Paragraphs[0].Append( pontok );
            table.Rows[1].Cells[0].Paragraphs[0].Append( beiroAlairas );
            table.Rows[1].Cells[1].Paragraphs[0].Append( induloAlairas );

            Border b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Beige);
            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );
        }
コード例 #3
0
ファイル: HianyzokLista.cs プロジェクト: belinyak/Ijasz2
        private void FirstPageFooter( ) {
            var footer = document.Footers.first;

            var footerTable = footer.InsertTable( 1, 2 );
            footerTable.Rows[0].Cells[1].Paragraphs[0].Append( "1. oldal" );
            footerTable.AutoFit = AutoFit.ColumnWidth;
            footerTable.Rows[0].Cells[0].Width = document.PageWidth;
            footerTable.Rows[0].Cells[1].Width = 70;

            Border c = new Border( Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black);
            footerTable.SetBorder( TableBorderType.InsideH, c );
            footerTable.SetBorder( TableBorderType.InsideV, c );
            footerTable.SetBorder( TableBorderType.Bottom, c );
            footerTable.SetBorder( TableBorderType.Top, c );
            footerTable.SetBorder( TableBorderType.Left, c );
            footerTable.SetBorder( TableBorderType.Right, c );
        }
コード例 #4
0
ファイル: Seged.cs プロジェクト: belinyak/Ijasz2
        public static void OldalSzamozas( DocX document ) {
            document.AddFooters( );
            var footer = document.Footers.odd;

            var footerTable = footer.InsertTable(1, 2);
            footerTable.Rows[0].Cells[1].Paragraphs[0].InsertPageNumber( PageNumberFormat.normal, 0 );
            footerTable.Rows[0].Cells[1].Paragraphs[0].Append( ". oldal" );
            footerTable.AutoFit = AutoFit.ColumnWidth;
            footerTable.Rows[0].Cells[0].Width = document.PageWidth;
            footerTable.Rows[0].Cells[1].Width = 70;

            Border c = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black );
            footerTable.SetBorder( TableBorderType.InsideH, c );
            footerTable.SetBorder( TableBorderType.InsideV, c );
            footerTable.SetBorder( TableBorderType.Bottom, c );
            footerTable.SetBorder( TableBorderType.Top, c );
            footerTable.SetBorder( TableBorderType.Left, c );
            footerTable.SetBorder( TableBorderType.Right, c );
        }
コード例 #5
0
        public ActionResult Xemhoadon(string idhoadon)
        {
            var hd       = _hoadonRepository.GetByTwoKey(idhoadon, HttpContext.Session.GetString("chinhanh"));
            var chinhanh = _dsdangkyhdRepository.getthongtinhd(HttpContext.Session.GetString("chinhanh"), HttpContext.Session.GetString("kyhieuhd"));
            var cthd     = _cthdvatRepository.ListChitietHoadon(idhoadon, HttpContext.Session.GetString("chinhanh"));
            //DocX doc = null;
            string webRootPath = _hostingEnvironment.WebRootPath;
            string fileName    = webRootPath + @"\Wordtemp\hddt.docx";
            var    doc         = DocX.Load(fileName);

            doc.AddCustomProperty(new CustomProperty("mausohd", hd.mausohd));
            doc.AddCustomProperty(new CustomProperty("kyhieu", hd.kyhieu));
            doc.AddCustomProperty(new CustomProperty("sohd", hd.hdvat));
            doc.AddCustomProperty(new CustomProperty("ngayhd", hd.ngayin.HasValue? "(Date)Ngày " + hd.ngayin.Value.ToString("dd") + " tháng " + hd.ngayin.Value.ToString("MM") + " năm " + hd.ngayin.Value.ToString("yyyy"):" Ngày.....tháng.....năm..... "));
            doc.AddCustomProperty(new CustomProperty("tencongty", chinhanh.tencn));
            doc.AddCustomProperty(new CustomProperty("mstcty", chinhanh.masothue));
            doc.AddCustomProperty(new CustomProperty("diachicty", chinhanh.diachi));
            doc.AddCustomProperty(new CustomProperty("taikhoancty", ""));
            doc.AddCustomProperty(new CustomProperty("dienthoaicty", chinhanh.dienthoai));
            doc.AddCustomProperty(new CustomProperty("donvikhach", hd.tenkh));
            doc.AddCustomProperty(new CustomProperty("tenkhach", string.IsNullOrEmpty(hd.tenkhach)?"":hd.tenkhach));
            doc.AddCustomProperty(new CustomProperty("mstkhach", string.IsNullOrEmpty(hd.msthue)?"":hd.msthue));
            doc.AddCustomProperty(new CustomProperty("diachikhach", string.IsNullOrEmpty(hd.diachi)?"":hd.diachi.Trim()));

            double totalsotiennt = 0;
            double totaltienthue = 0;
            double totaltienppv  = 0;
            double total         = 0;
            var    tbChitiet     = doc.AddTable(1, 6);

            tbChitiet.SetWidths(new float[] { 50, 320, 100, 120, 80, 100 });

            tbChitiet.Rows[0].Cells[0].Paragraphs[0].Append("STT" + System.Environment.NewLine + " Order").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
            tbChitiet.Rows[0].Cells[1].Paragraphs[0].Append("Tên hàng hoá, dịch vụ" + System.Environment.NewLine + " Description").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
            tbChitiet.Rows[0].Cells[2].Paragraphs[0].Append("Số tiền" + System.Environment.NewLine + " Amount").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
            tbChitiet.Rows[0].Cells[3].Paragraphs[0].Append("Tiền phí dịch vụ" + System.Environment.NewLine + " Service Chargers").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
            tbChitiet.Rows[0].Cells[4].Paragraphs[0].Append("Thuế suất" + System.Environment.NewLine + " VAT Rate%").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment  = Alignment.center;
            tbChitiet.Rows[0].Cells[5].Paragraphs[0].Append("Tiền thuế" + System.Environment.NewLine + " VAT Amount").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
            foreach (var i in cthd)
            {
                var    row      = tbChitiet.InsertRow();
                double ptvat    = Math.Round((i.vat / 100.0), 2);
                double tienthue = Math.Round((double)i.sotien * ptvat, 0);
                double tienppv  = Math.Round((double)i.sotien * ((double)i.ppv / 100.0), 0);
                row.Cells[0].Paragraphs[0].Append(i.sttdong == 0?"": i.sttdong.ToString()).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.center;
                row.Cells[1].Paragraphs[0].Append(i.diengiai).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.left;
                row.Cells[2].Paragraphs[0].Append(string.Format("{0:#,##0}", i.sotiennt)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
                row.Cells[3].Paragraphs[0].Append(string.Format("{0:#,##0}", tienppv)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment    = Alignment.right;
                row.Cells[4].Paragraphs[0].Append(i.vat.ToString()).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
                row.Cells[5].Paragraphs[0].Append(string.Format("{0:#,##0}", tienthue)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;

                totalsotiennt += (double)i.sotiennt;
                totaltienthue += tienthue;
                totaltienppv  += tienppv;
                total         += (double)i.sotiennt + tienthue + tienppv;
                //row.Cells[0].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
                //row.Cells[1].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
                //row.Cells[2].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
                //row.Cells[3].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
                //row.Cells[4].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
                //row.Cells[5].SetBorder(TableCellBorderType.Bottom, new Novacode.Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
            }
            // set no border cho table
            Novacode.Border b = new Novacode.Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Transparent);
            tbChitiet.SetBorder(TableBorderType.InsideH, b);
            tbChitiet.SetBorder(TableBorderType.InsideV, b);
            tbChitiet.SetBorder(TableBorderType.Bottom, b);
            tbChitiet.SetBorder(TableBorderType.Top, b);
            tbChitiet.SetBorder(TableBorderType.Left, b);
            tbChitiet.SetBorder(TableBorderType.Right, b);

            // insert dong subtotal
            var rowsub = tbChitiet.InsertRow();

            rowsub.Cells[1].Paragraphs[0].Append("Cộng (Subtotal)").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
            rowsub.Cells[2].Paragraphs[0].Append(string.Format("{0:#,##0}", totalsotiennt)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
            rowsub.Cells[3].Paragraphs[0].Append(string.Format("{0:#,##0}", totaltienppv)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment  = Alignment.right;
            rowsub.Cells[5].Paragraphs[0].Append(string.Format("{0:#,##0}", totaltienthue)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
            // insert dong Total
            var rowstotal = tbChitiet.InsertRow();

            rowstotal.Cells[1].Paragraphs[0].Append("Tổng cộng(Total)").Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;
            rowstotal.Cells[2].Paragraphs[0].Append(string.Format("{0:#,##0}", total)).Color(Color.Black).Font("Times New Roman").FontSize(10).Alignment = Alignment.right;

            doc.InsertTable(tbChitiet);
            doc.InsertParagraph("Số tiền bằng chữ-Inwords: " + SoSangChu.DoiSoSangChu(Math.Round(total, 0).ToString())).Color(Color.Black).Font("Times New Roman").FontSize(11).Alignment = Alignment.left;

            MemoryStream stream = new MemoryStream();

            doc.SaveAs(stream);
            stream.Position = 0;
            //Download Word document in the browser

            return(File(stream, "application/msword", "hoadon_" + DateTime.Now + ".docx"));
        }
コード例 #6
0
ファイル: Table.cs プロジェクト: WordDocX/DocX
        /// <summary>
        /// Set a table border
        /// Added by lckuiper @ 20101117
        /// </summary>
        /// <example>
        /// <code>
        /// // Create a new document.
        ///using (DocX document = DocX.Create("Test.docx"))
        ///{
        ///    // Insert a table into this document.
        ///    Table t = document.InsertTable(3, 3);
        ///
        ///    // Create a large blue border.
        ///    Border b = new Border(BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Blue);
        ///
        ///    // Set the tables Top, Bottom, Left and Right Borders to b.
        ///    t.SetBorder(TableBorderType.Top, b);
        ///    t.SetBorder(TableBorderType.Bottom, b);
        ///    t.SetBorder(TableBorderType.Left, b);
        ///    t.SetBorder(TableBorderType.Right, b);
        ///
        ///    // Save the document.
        ///    document.Save();
        ///}
        /// </code>
        /// </example>
        /// <param name="borderType">The table border to set</param>
        /// <param name="border">Border object to set the table border</param>
        public void SetBorder(TableBorderType borderType, Border border)
        {
            /*
             * Get the tblPr (table properties) element for this Table,
             * null will be return if no such element exists.
             */
            XElement tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
            if (tblPr == null)
            {
                Xml.SetElementValue(XName.Get("tblPr", DocX.w.NamespaceName), string.Empty);
                tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
            }

            /*
             * Get the tblBorders (table borders) element for this Table,
             * null will be return if no such element exists.
             */
            XElement tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
            if (tblBorders == null)
            {
                tblPr.SetElementValue(XName.Get("tblBorders", DocX.w.NamespaceName), string.Empty);
                tblBorders = tblPr.Element(XName.Get("tblBorders", DocX.w.NamespaceName));
            }

            /*
             * Get the 'borderType' (table border) element for this Table,
             * null will be return if no such element exists.
             */
            var tbordertype = borderType.ToString();
            // only lower the first char of string (because of insideH and insideV)
            tbordertype = tbordertype.Substring(0, 1).ToLower() + tbordertype.Substring(1);

            XElement tblBorderType = tblBorders.Element(XName.Get(borderType.ToString(), DocX.w.NamespaceName));
            if (tblBorderType == null)
            {
                tblBorders.SetElementValue(XName.Get(tbordertype, DocX.w.NamespaceName), string.Empty);
                tblBorderType = tblBorders.Element(XName.Get(tbordertype, DocX.w.NamespaceName));
            }

            // get string value of border style
            string borderstyle = border.Tcbs.ToString().Substring(5);
            borderstyle = borderstyle.Substring(0, 1).ToLower() + borderstyle.Substring(1);

            // The val attribute is used for the border style
            tblBorderType.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), borderstyle);

            if (border.Tcbs != BorderStyle.Tcbs_nil)
            {
                int size;
                switch (border.Size)
                {
                    case BorderSize.one: size = 2; break;
                    case BorderSize.two: size = 4; break;
                    case BorderSize.three: size = 6; break;
                    case BorderSize.four: size = 8; break;
                    case BorderSize.five: size = 12; break;
                    case BorderSize.six: size = 18; break;
                    case BorderSize.seven: size = 24; break;
                    case BorderSize.eight: size = 36; break;
                    case BorderSize.nine: size = 48; break;
                    default: size = 2; break;
                }

                // The sz attribute is used for the border size
                tblBorderType.SetAttributeValue(XName.Get("sz", DocX.w.NamespaceName), (size).ToString());

                // The space attribute is used for the cell spacing (probably '0')
                tblBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());

                // The color attribute is used for the border color
                tblBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), border.Color.ToHex());
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: ThatCSharpGuy/DocX-sample
        private static void Main(string[] args)
        {
            var teacher = GetMostActiveTeacher();
            var lectures = GetLecturesForTeacher(teacher.Id);

            using (var document = DocX.Create("Prueba.docx"))
            {
                var titleParagraph = document.InsertParagraph();
                titleParagraph.Append("Reporte " + teacher.LastName).Heading(HeadingType.Heading1);

                var reportParagraph = document.InsertParagraph();
                reportParagraph.Append ("Este es un reporte perteneciente a las clases que imparte ");
                reportParagraph.Append (teacher.GivenName + " " + teacher.LastName).Bold().Append(", generado en ");
                reportParagraph.Append (DateTime.Now.ToShortDateString ()).Italic().Append (". ")
                    .Append ("El profesor/ra ").Append(teacher.LastName).Font(new FontFamily("Arial Black"))
                    .Append(" imparte actualmente ")
                    .Append(lectures.Length + " asignaturas.").Color(Color.Blue).Italic().Bold();

                document.AddHeaders ();
                document.AddFooters ();

                var header = document.Headers.odd.InsertParagraph ();
                header.Append ("Reporte - That C# Guy").Font(new FontFamily("Courier New"));

                document.Footers.odd.PageNumbers = true;

                var table = document.InsertTable (1, 3);

                table.AutoFit = AutoFit.Window;
                var border = new Border (BorderStyle.Tcbs_single, BorderSize.one, 0, Color.Black);
                table.SetBorder (TableBorderType.InsideH, border);
                table.SetBorder (TableBorderType.InsideV, border);
                table.SetBorder (TableBorderType.Top, border);
                table.SetBorder (TableBorderType.Right, border);
                table.SetBorder (TableBorderType.Bottom, border);
                table.SetBorder (TableBorderType.Left, border);

                table.Design = TableDesign.ColorfulGrid;

                var tableHeaders = table.Rows[0];
                tableHeaders.Cells[0].InsertParagraph().Append("ID").Bold();
                tableHeaders.Cells[1].InsertParagraph().Append("Clase").Bold();
                tableHeaders.Cells[2].InsertParagraph().Append("Nivel").Bold();

                foreach (var lecture in lectures)
                {
                    var tableRow = table.InsertRow();
                    tableRow.Cells[0].InsertParagraph().Append (lecture.Id.ToString());
                    tableRow.Cells[1].InsertParagraph().Append(lecture.Name);
                    tableRow.Cells[2].InsertParagraph().Append(lecture.Level);
                }

                document.Save();
            }

            using (var template = DocX.Load ("template.docx"))
            {
                template.ReplaceText("esta entrada", "este post sobre DocX");
                template.ReplaceText("querido", "querido y respetable");
                template.ReplaceText("Facebook", "Twitter");
                template.ReplaceText("correo electrónico", "*****@*****.**");

                template.SaveAs("out.docx");
            }
        }
コード例 #8
0
ファイル: Table.cs プロジェクト: kenjiuno/enex2docx
        /// <summary>
        /// Set the table cell border
        /// Added by lckuiper @ 20101117
        /// </summary>
        /// <example>
        /// <code>
        ///// Create a new document.
        ///using (DocX document = DocX.Create("Test.docx"))
        ///{
        ///    // Insert a table into this document.
        ///    Table t = document.InsertTable(3, 3);
        ///
        ///    // Get the center cell.
        ///    Cell center = t.Rows[1].Cells[1];
        ///
        ///    // Create a large blue border.
        ///    Border b = new Border(BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Blue);
        ///
        ///    // Set the center cells Top, Bottom, Left and Right Borders to b.
        ///    center.SetBorder(TableCellBorderType.Top, b);
        ///    center.SetBorder(TableCellBorderType.Bottom, b);
        ///    center.SetBorder(TableCellBorderType.Left, b);
        ///    center.SetBorder(TableCellBorderType.Right, b);
        ///
        ///    // Save the document.
        ///    document.Save();
        ///}
        /// </code>
        /// </example>
        /// <param name="borderType">Table Cell border to set</param>
        /// <param name="border">Border object to set the table cell border</param>
        public void SetBorder(TableCellBorderType borderType, Border border)
        {
            /*
             * Get the tcPr (table cell properties) element for this Cell,
             * null will be return if no such element exists.
             */
            XElement tcPr = Xml.Element(XName.Get("tcPr", DocX.w.NamespaceName));
            if (tcPr == null)
            {
                Xml.SetElementValue(XName.Get("tcPr", DocX.w.NamespaceName), string.Empty);
                tcPr = Xml.Element(XName.Get("tcPr", DocX.w.NamespaceName));
            }

            /*
             * Get the tblBorders (table cell borders) element for this Cell,
             * null will be return if no such element exists.
             */
            XElement tcBorders = tcPr.Element(XName.Get("tcBorders", DocX.w.NamespaceName));
            if (tcBorders == null)
            {
                tcPr.SetElementValue(XName.Get("tcBorders", DocX.w.NamespaceName), string.Empty);
                tcBorders = tcPr.Element(XName.Get("tcBorders", DocX.w.NamespaceName));
            }

            /*
             * Get the 'borderType' (table cell border) element for this Cell,
             * null will be return if no such element exists.
             */
            string tcbordertype;
            switch (borderType)
            {
                case TableCellBorderType.TopLeftToBottomRight:
                    tcbordertype = "tl2br";
                    break;
                case TableCellBorderType.TopRightToBottomLeft:
                    tcbordertype = "tr2bl";
                    break;
                default:
                    // enum to string
                    tcbordertype = borderType.ToString();
                    // only lower the first char of string (because of insideH and insideV)
                    tcbordertype = tcbordertype.Substring(0, 1).ToLower() + tcbordertype.Substring(1);
                    break;
            }

            XElement tcBorderType = tcBorders.Element(XName.Get(borderType.ToString(), DocX.w.NamespaceName));
            if (tcBorderType == null)
            {
                tcBorders.SetElementValue(XName.Get(tcbordertype, DocX.w.NamespaceName), string.Empty);
                tcBorderType = tcBorders.Element(XName.Get(tcbordertype, DocX.w.NamespaceName));
            }

            // get string value of border style
            string borderstyle = border.Tcbs.ToString().Substring(5);
            borderstyle = borderstyle.Substring(0, 1).ToLower() + borderstyle.Substring(1);

            // The val attribute is used for the border style
            tcBorderType.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), borderstyle);

            int size;
            switch (border.Size)
            {
                case BorderSize.one: size = 2; break;
                case BorderSize.two: size = 4; break;
                case BorderSize.three: size = 6; break;
                case BorderSize.four: size = 8; break;
                case BorderSize.five: size = 12; break;
                case BorderSize.six: size = 18; break;
                case BorderSize.seven: size = 24; break;
                case BorderSize.eight: size = 36; break;
                case BorderSize.nine: size = 48; break;
                default: size = 2; break;
            }

            // The sz attribute is used for the border size
            tcBorderType.SetAttributeValue(XName.Get("sz", DocX.w.NamespaceName), (size).ToString());

            // The space attribute is used for the cell spacing (probably '0')
            tcBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());

            // The color attribute is used for the border color
            tcBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), ColorTranslator.ToHtml(border.Color));
        }
コード例 #9
0
ファイル: Nyomtat.cs プロジェクト: laszlo-dobcsanyi/Labor
        MinBizDataTablazatFormazasa( Table _table )
        {
            _table.AutoFit = AutoFit.Contents;

            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );
        }
コード例 #10
0
ファイル: HianyzokLista.cs プロジェクト: belinyak/Ijasz2
        private void HeaderTablazat( ) {
            var tablazatFejlec = document.Headers.odd;

            var table = document.AddTable( 1, 6 );
            table.AutoFit = AutoFit.ColumnWidth;

            table.Rows[0].Cells[0].Paragraphs[0].Append( "Sorszám" );
            table.Rows[0].Cells[1].Paragraphs[0].Append( "Név" );
            table.Rows[0].Cells[2].Paragraphs[0].Append( "Íjtípus" );
            table.Rows[0].Cells[3].Paragraphs[0].Append( "Kor" );
            table.Rows[0].Cells[4].Paragraphs[0].Append( "Egyesület" );
            table.Rows[0].Cells[5].Paragraphs[0].Append( "Csapat" );

            #region Formazas
            table.Alignment = Alignment.center;

            Border b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
            Border c = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);

            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );

            for( int i = 0; i < 6; i++ ) {
                table.Rows[0].Cells[i].SetBorder( TableCellBorderType.Bottom, c );
            }

            foreach( Row row in table.Rows ) {
                row.Cells[0].Width = 70;
                row.Cells[1].Width = 200;
                row.Cells[2].Width = 150;
                row.Cells[3].Width = 40;
                row.Cells[4].Width = 150;
                row.Cells[5].Width = 70;
            }

            table.AutoFit = AutoFit.ColumnWidth;
            #endregion
            tablazatFejlec.InsertTable( table );
        }
コード例 #11
0
ファイル: Beirolap.cs プロジェクト: belinyak/Ijasz2
        private void InduloTablazat( ) {
            var table = document.AddTable(4, 2);
            table.Alignment = Alignment.left;

            table.Rows[0].Cells[0].Paragraphs[0].Append( Feliratok.Indulo.Sorszam );
            table.Rows[0].Cells[0].Paragraphs[0].Append( induloAdat.Sorszam.ToString( ) ).FontSize( 14 ).Bold( );
            table.Rows[1].Cells[0].Paragraphs[0].Append( Feliratok.Indulo.Nev );
            table.Rows[1].Cells[0].Paragraphs[0].Append( induloAdat.Nev ).FontSize( 14 ).Bold( );
            table.Rows[2].Cells[0].Paragraphs[0].Append( Feliratok.Indulo.Egyesulet );
            table.Rows[2].Cells[0].Paragraphs[0].Append( induloAdat.Egyesulet ).Bold( );
            table.Rows[3].Cells[0].Paragraphs[0].Append( Feliratok.Indulo.Ijtipus );
            table.Rows[3].Cells[0].Paragraphs[0].Append( induloAdat.Ijtipus ).Bold( );

            table.Rows[0].Cells[1].Paragraphs[0].Append( Feliratok.Indulo.Csapat );
            table.Rows[0].Cells[1].Paragraphs[0].Append( induloAdat.Csapat.ToString( ) ).Bold( );
            table.Rows[1].Cells[1].Paragraphs[0].Append( Feliratok.Indulo.Kor );
            table.Rows[1].Cells[1].Paragraphs[0].Append( induloAdat.Kor.ToString( ) ).Bold( );
            table.Rows[2].Cells[1].Paragraphs[0].Append( Feliratok.Indulo.Korosztaly );
            table.Rows[2].Cells[1].Paragraphs[0].Append( induloAdat.KorosztalyMegnevezes ).Bold( );
            if( !string.IsNullOrEmpty( induloAdat.Engedely ) ) {
                table.Rows[3].Cells[1].Paragraphs[0].Append( Feliratok.Indulo.Engedely );
                table.Rows[4].Cells[1].Paragraphs[0].Append( induloAdat.Engedely ).Bold( );
            }
            table.AutoFit = AutoFit.Contents;

            var b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );

            document.InsertTable( table );
            document.InsertParagraph( );
        }
コード例 #12
0
        private void RenderAsTable(IEnumerable<DocumentIdea> ideas)
        {
            foreach (DocumentIdea idea in FilterIdeas(ideas))
            {
                Table table = _wordDocument.AddTable(3, 2);

                table.Design = TableDesign.TableGrid;

                table.AutoFit = AutoFit.Contents;

                Border border = new Border();
                //border.Color = System.Drawing.Color.LightGray;
                border.Tcbs = BorderStyle.Tcbs_none;

                ApplyStyleToTableHeading(table.Rows[0].Cells[0].Paragraphs.First().Append("Finding:"));
                table.Rows[0].Cells[1].Paragraphs.First().Append(idea.Text);
                ApplyStyleToTableHeading(table.Rows[1].Cells[0].Paragraphs.First().Append("Thoughts:"));
                table.Rows[1].Cells[1].Paragraphs.First().Append(String.IsNullOrWhiteSpace(idea.Comment) ? "N/A" : idea.Comment);
                ApplyStyleToTableHeading(table.Rows[2].Cells[0].Paragraphs.First().Append("Tags:"));
                ApplyStyleToTableHeading(table.Rows[2].Cells[1].Paragraphs.First().Append(FormatTags(idea)));

                if (String.IsNullOrWhiteSpace(idea.Comment))
                {
                    table.RemoveRow(1);
                }

                table.Rows[0].Cells[0].Width = 100f;

                foreach (var row in table.Rows)
                {
                    foreach (var cell in row.Cells)
                    {
                        cell.SetBorder(TableCellBorderType.Bottom, border);
                        cell.SetBorder(TableCellBorderType.Top, border);
                        cell.SetBorder(TableCellBorderType.Right, border);
                        cell.SetBorder(TableCellBorderType.Left, border);
                    }
                }

                _wordDocument.InsertTable(table);
                _wordDocument.InsertParagraph();
            }
        }
コード例 #13
0
        private void VersenySorozatAdatokTablazat( Header header ) {
            var table = Document.AddTable(1, 2);
            table.Alignment = Alignment.left;
            table.Rows[0].Cells[0].Paragraphs[0].Append( Feliratok.Versenysorozat.Megnevezes );
            table.Rows[0].Cells[0].Paragraphs[0].Append( string.IsNullOrEmpty( Versenysorozat.Megnevezes ) ? Versenysorozat.Azonosito : Versenysorozat.Megnevezes ).Bold( );

            table.AutoFit = AutoFit.Contents;

            var b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.AliceBlue);
            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );
            header.InsertTable( table );
        }
コード例 #14
0
        public void CreateSampleDocument()
        {
            // SOURCE:
            // Heading Paragraph
            string myH1 = "SoftUni OOP Game Contest";

            // Image path 
            string imagePath = @"../../Source/rpg-game.png";

            // Paragraph
            string text1a = "SoftUni is organizing a contest for the best ";
            string text1b = "role playing game";
            string text1c = " from the OOP teamwork projects. The winning teams will receive a ";
            string text1d = "grand prize";
            string text1e = "!";
            string text1f = "The game should be:";

            // BulletList
            string[] myBulletList = new string[] { "Properly structured and follow all good OOP practices", "Awesome", "..Very Awesome" };

            // Table content
            string[,] tableContent = new string[4, 3] { { "Team", "Game", "Points" }, { "-", "-", "-" }, { "-", "-", "-" }, { "-", "-", "-" } };

            // Paragraph 2
            string text2a = "The top 3 teams will receive a ";
            string text2b = "SPECTACULAR";
            string text2c = " prize:";

            // Paragraph 3
            string text3 = @"A HANDSHAKE FROM NAKOV";

            try
            {
                // Modify to suit your machine:
                string fileName = @"./DocXExample.docx";

                using (DocX document = DocX.Create(fileName))
                {
                    // A formatting object for our headline:
                    var headLineFormat = new Formatting();
                    headLineFormat.FontFamily = new System.Drawing.FontFamily("Arial");
                    headLineFormat.Size = 18D;
                    headLineFormat.Position = 20;
                    headLineFormat.Bold = true;

                    Paragraph p1 = document.InsertParagraph(myH1, false, headLineFormat);
                    p1.Alignment = Alignment.center;

                    // Add an Image to the docx file
                    Novacode.Image img = document.AddImage(imagePath);

                    Paragraph imgParagraph = document.InsertParagraph(string.Empty, false);
                    Picture pic1 = img.CreatePicture();

                    // Set Size
                    pic1.Height = 250;
                    pic1.Width = 630;
                    imgParagraph.InsertPicture(pic1, 0);

                    // Add new Paragraph(3)
                    Paragraph p3 = document.InsertParagraph();
                    p3.AppendLine().Append(text1a)
                        .Append(text1b)
                        .Bold()
                        .Append(text1c)
                        .Append(text1d)
                        .Bold()
                        .UnderlineStyle(UnderlineStyle.singleLine)
                        .Append(text1e)
                        .AppendLine()
                        .Append(text1f)
                        .AppendLine();

                    // Add Bullet list
                    var bulletedList = document.AddList(null, 0, ListItemType.Bulleted);
                    foreach (var item in myBulletList)
                    {
                        document.AddListItem(bulletedList, item);
                    }

                    List l = document.InsertList(bulletedList);
                    Paragraph emptyParagrph = document.InsertParagraph(string.Empty, false);

                    // Add table
                    Table table1 = document.InsertTable(tableContent.GetLength(0), tableContent.GetLength(1));
                    Border myTableBorder = new Border(BorderStyle.Tcbs_single, BorderSize.two, 0, Color.Black);
                    for (int i = 0; i < tableContent.GetLength(0); i++)
                    {
                        table1.Rows[i].Height = 25;
                        for (int j = 0; j < tableContent.GetLength(1); j++)
                        {
                            if (i == 0)
                            {
                                table1.Rows[i].Cells[j].FillColor = Color.SteelBlue;
                            }

                            table1.Rows[i].Cells[j].Paragraphs[0].Append(tableContent[i, j]);
                            table1.Rows[i].Cells[j].SetBorder(TableCellBorderType.Left, myTableBorder);
                            table1.Rows[i].Cells[j].SetBorder(TableCellBorderType.Top, myTableBorder);
                            table1.Rows[i].Cells[j].SetBorder(TableCellBorderType.Right, myTableBorder);
                            table1.Rows[i].Cells[j].SetBorder(TableCellBorderType.Bottom, myTableBorder);
                            table1.Rows[i].Cells[j].Width = 20;
                            table1.Rows[i].Cells[j].VerticalAlignment = VerticalAlignment.Center;
                            table1.Rows[i].Cells[j].Paragraphs[0].Alignment = Alignment.center;
                        }
                    }

                    table1.AutoFit = AutoFit.Window;
                    table1.Alignment = Alignment.center;
                    Paragraph emptyParagrph2 = document.InsertParagraph(string.Empty, false);

                    // Add new Paragraph(4)
                    Paragraph p4 = document.InsertParagraph();
                    p4.Append(text2a).Append(text2b).Bold().Append(text2c);
                    p4.Alignment = Alignment.center;

                    // Add new Paragraph(5)
                    var prizeFormat = new Formatting();
                    prizeFormat.FontFamily = new System.Drawing.FontFamily("Arial");
                    prizeFormat.Size = 36D;
                    prizeFormat.Position = 12;
                    prizeFormat.Bold = true;

                    Paragraph p5 = document.InsertParagraph(string.Empty, false, prizeFormat);
                    p5.Append(text3).Bold().UnderlineStyle(UnderlineStyle.singleLine).FontSize(26d).Color(Color.SteelBlue);
                    p5.Alignment = Alignment.center;

                    // Save to the output directory:
                    document.Save();

                    // Open in Word:
                    Process.Start("WINWORD.EXE", fileName);
                }
            }
            catch (Exception x)
            {
                // throw new Exception("Cannot create word document! Error: " + x.ToString());
                Console.WriteLine("Cannot create word document! Error: " + x.ToString());
            }
        }
コード例 #15
0
        private void TablazatFormazas( Table table ) {
            table.AutoFit = AutoFit.ColumnWidth;
            for( int i = 0; i < table.Rows.Count; i++ ) {
                table.Rows[i].Cells[0].Width = 30;
                table.Rows[i].Cells[1].Width = 50;
                table.Rows[i].Cells[2].Width = 200;
                table.Rows[i].Cells[3].Width = 50;
                table.Rows[i].Cells[4].Width = 200;
                table.Rows[i].Cells[5].Width = 70;
                table.Rows[i].Cells[6].Width = 70;
            }

            Border c = new Border(Novacode.BorderStyle.Tcbs_none,BorderSize.seven, 0, Color.Black);
            Border d = new Border(Novacode.BorderStyle.Tcbs_single,BorderSize.five, 0, Color.Black);

            //table.SetBorder( TableBorderType.InsideH, d );
            //table.SetBorder( TableBorderType.InsideV, c );
            //table.SetBorder( TableBorderType.Bottom, c );
            //table.SetBorder( TableBorderType.Top, c );
            //table.SetBorder( TableBorderType.Left, c );
            //table.SetBorder( TableBorderType.Right, c );
        }
コード例 #16
0
ファイル: Nyomtat.cs プロジェクト: laszlo-dobcsanyi/Labor
        KonszignacioDataTableFormazas( Table _table )
        {
            _table.AutoFit = AutoFit.Contents;
            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.two, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );

            for ( int i = 0 ; i < _table.Rows[ 0 ].Cells.Count ; i++ )
            {
                _table.Rows[ 0 ].Cells[ i ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single, BorderSize.six, 0, Color.Black ) );
                _table.Rows[ 0 ].Cells[ i ].SetBorder( TableCellBorderType.Bottom, new Border( BorderStyle.Tcbs_single, BorderSize.six, 0, Color.Black ) );
            }
            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                if ( _table.Rows[ i ].Cells[ 1 ].Paragraphs[ 0 ].Text.Contains( "összesen" ) )
                {
                    for ( int j = 0 ;
                         j < _table.Rows[ i ].Cells.Count ;
                         j++ )
                    {
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single,
                                                                                       BorderSize.six, 0, Color.Black ) );
                    }
                }
                else if ( _table.Rows[ i ].Cells[ 1 ].Paragraphs[ 0 ].Text.Contains( "elszállítás" ) )
                {
                    for ( int j = 0 ;
                         j < _table.Rows[ i ].Cells.Count ;
                         j++ )
                    {
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single,
                                                                                               BorderSize.six, 0, Color.Black ) );
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Bottom, new Border( BorderStyle.Tcbs_single,
                                                                                                BorderSize.six, 0, Color.Black ) );
                    }
                    _table.Rows[ i ].Cells[ 0 ].SetBorder( TableCellBorderType.Left, new Border( BorderStyle.Tcbs_single,
                                                                                            BorderSize.six, 0, Color.Black ) );
                    _table.Rows[ i ].Cells[ 6 ].SetBorder( TableCellBorderType.Right, new Border( BorderStyle.Tcbs_single,
                                                                                            BorderSize.six, 0, Color.Black ) );
                }
            }

            //konszig táblázat-BN
            _table.AutoFit = AutoFit.ColumnWidth;

            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                _table.Rows[ i ].Cells[ 0 ].Width = 45;     //sorszám
                _table.Rows[ i ].Cells[ 1 ].Width = 210;    //megnevezés
                _table.Rows[ i ].Cells[ 2 ].Width = 60;     //hordó
                _table.Rows[ i ].Cells[ 3 ].Width = 50;     //sarzs
                _table.Rows[ i ].Cells[ 4 ].Width = 80;     //súly
                _table.Rows[ i ].Cells[ 5 ].Width = 160;    //h.típus
                _table.Rows[ i ].Cells[ 6 ].Width = 110;    //dátum
            }
            _table.AutoFit = AutoFit.ColumnWidth;
        }
コード例 #17
0
ファイル: Nyomtat.cs プロジェクト: laszlo-dobcsanyi/Labor
        KonszignacioFejlecTablazatFormazas( Table _table )
        {
            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );

            //konszig táblázat fejléc-BN
            _table.AutoFit = AutoFit.ColumnWidth;

            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                _table.Rows[ i ].Cells[ 0 ].Width = 80;         //vevő fix
                _table.Rows[ i ].Cells[ 1 ].Width = 300;        //vevő
                _table.Rows[ i ].Cells[ 2 ].Width = 60;         //feladó fix
                _table.Rows[ i ].Cells[ 3 ].Width = 300;        //feladó
            }
            _table.AutoFit = AutoFit.ColumnWidth;
        }
コード例 #18
0
ファイル: Table.cs プロジェクト: WordDocX/DocX
        /// <summary>
        /// Get a table cell border
        /// Added by lckuiper @ 20101117
        /// </summary>
        /// <param name="borderType">The table cell border to get</param>
        public Border GetBorder(TableCellBorderType borderType)
        {
            // instance with default border values
            var b = new Border();

            /*
             * Get the tcPr (table cell properties) element for this Cell,
             * null will be return if no such element exists.
             */
            XElement tcPr = Xml.Element(XName.Get("tcPr", DocX.w.NamespaceName));
            if (tcPr == null)
            {
                // uses default border style
            }

            /*
             * Get the tcBorders (table cell borders) element for this Cell,
             * null will be return if no such element exists.
             */
            XElement tcBorders = tcPr.Element(XName.Get("tcBorders", DocX.w.NamespaceName));
            if (tcBorders == null)
            {
                // uses default border style
            }

            /*
             * Get the 'borderType' (cell border) element for this Cell,
             * null will be return if no such element exists.
             */
            var tcbordertype = borderType.ToString();

            switch (tcbordertype)
            {
                case "TopLeftToBottomRight":
                    tcbordertype = "tl2br";
                    break;
                case "TopRightToBottomLeft":
                    tcbordertype = "tr2bl";
                    break;
                default:
                    // only lower the first char of string (because of insideH and insideV)
                    tcbordertype = tcbordertype.Substring(0, 1).ToLower() + tcbordertype.Substring(1);
                    break;
            }

            XElement tcBorderType = tcBorders.Element(XName.Get(tcbordertype, DocX.w.NamespaceName));
            if (tcBorderType == null)
            {
                // uses default border style
            }

            // The val attribute is used for the border style
            XAttribute val = tcBorderType.Attribute(XName.Get("val", DocX.w.NamespaceName));
            // If val is null, this cell contains no border information.
            if (val == null)
            {
                // uses default border style
            }
            else
            {
                try
                {
                    string bordertype = "Tcbs_" + val.Value;
                    b.Tcbs = (BorderStyle)Enum.Parse(typeof(BorderStyle), bordertype);
                }

                catch
                {
                    val.Remove();
                    // uses default border style
                }
            }

            // The sz attribute is used for the border size
            XAttribute sz = tcBorderType.Attribute(XName.Get("sz", DocX.w.NamespaceName));
            // If sz is null, this border contains no size information.
            if (sz == null)
            {
                // uses default border style
            }
            else
            {
                // If sz is not an int, something is wrong with this attributes value, so remove it
                int numerical_size;
                if (!int.TryParse(sz.Value, out numerical_size))
                    sz.Remove();
                else
                {
                    switch (numerical_size)
                    {
                        case 2: b.Size = BorderSize.one; break;
                        case 4: b.Size = BorderSize.two; break;
                        case 6: b.Size = BorderSize.three; break;
                        case 8: b.Size = BorderSize.four; break;
                        case 12: b.Size = BorderSize.five; break;
                        case 18: b.Size = BorderSize.six; break;
                        case 24: b.Size = BorderSize.seven; break;
                        case 36: b.Size = BorderSize.eight; break;
                        case 48: b.Size = BorderSize.nine; break;
                        default: b.Size = BorderSize.one; break;
                    }
                }
            }

            // The space attribute is used for the border spacing (probably '0')
            XAttribute space = tcBorderType.Attribute(XName.Get("space", DocX.w.NamespaceName));
            // If space is null, this border contains no space information.
            if (space == null)
            {
                // uses default border style
            }
            else
            {
                // If space is not an int, something is wrong with this attributes value, so remove it
                int borderspace;
                if (!int.TryParse(space.Value, out borderspace))
                {
                    space.Remove();
                    // uses default border style
                }
                else
                {
                    b.Space = borderspace;
                }
            }

            // The color attribute is used for the border color
            XAttribute color = tcBorderType.Attribute(XName.Get("color", DocX.w.NamespaceName));
            if (color == null)
            {
                // uses default border style
            }
            else
            {
                // If color is not a Color, something is wrong with this attributes value, so remove it
                try
                {
                    b.Color = ColorTranslator.FromHtml(string.Format("#{0}", color.Value));
                }
                catch
                {
                    color.Remove();
                    // uses default border style
                }
            }
            return b;
        }
コード例 #19
0
        private void AdatTablazatFormazas( Table table ) {
            Border b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
            Border c = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);

            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );

            for( int i = 0; i < 4; i++ ) {
                table.Rows[0].Cells[i].SetBorder( TableCellBorderType.Bottom, c );
            }

            table.AutoFit = AutoFit.ColumnWidth;
            foreach( Row row in table.Rows ) {
                row.Cells[0].Width = 100;
                row.Cells[1].Width = 250;
                row.Cells[2].Width = 250;
                row.Cells[3].Width = 100;
            }

            foreach( Row row in table.Rows ) {
                row.Height = 20;
            }
        }
コード例 #20
0
ファイル: VersenyEredmenyLap.cs プロジェクト: belinyak/Ijasz2
        private void VersenyAdatokTablazat( Header header ) {
            var table = document.AddTable(3, 2);
            table.Alignment = Alignment.left;
            table.Rows[0].Cells[0].Paragraphs[0].Append( Feliratok.Verseny.Megnevezes );
            table.Rows[0].Cells[0].Paragraphs[0].Append( string.IsNullOrEmpty( versenyAdatok.Megnevezes ) ? versenyAdatok.Azonosito : versenyAdatok.Megnevezes ).Bold( );

            table.Rows[1].Cells[0].Paragraphs[0].Append( Feliratok.Verseny.Datum );
            table.Rows[1].Cells[0].Paragraphs[0].Append( versenyAdatok.Datum ).Bold( );

            if( !string.IsNullOrEmpty( versenyAdatok.VersenysorozatAzonosito ) ) {
                table.Rows[2].Cells[0].Paragraphs[0].Append( Feliratok.Versenysorozat.Megnevezes );
                table.Rows[2].Cells[0].Paragraphs[0].Append( string.IsNullOrEmpty( versenyAdatok.VersenysorozatMegnevezes ) ? versenyAdatok.VersenysorozatAzonosito : versenyAdatok.VersenysorozatMegnevezes ).Bold( );
            }

            table.Rows[0].Cells[1].Paragraphs[0].Append( Feliratok.Verseny.OsszesPont );
            table.Rows[0].Cells[1].Paragraphs[0].Append( ( versenyAdatok.OsszesPont * 10 ).ToString( ) ).Bold( );

            table.Rows[1].Cells[1].Paragraphs[0].Append( Feliratok.Verseny.IndulokSzama );
            table.Rows[1].Cells[1].Paragraphs[0].Append( versenyAdatok.IndulokSzama.ToString( ) ).Bold( );

            table.AutoFit = AutoFit.Contents;

            var b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.AliceBlue);
            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );
            header.InsertTable( table );
        }
コード例 #21
0
ファイル: HianyzokLista.cs プロジェクト: belinyak/Ijasz2
        private void HianyzokListaTablazat( ) {

            Table table = document.AddTable( versenyAdatok.HianyzokSzama + 1, 6 );

            table.Rows[0].Cells[0].Paragraphs[0].Append( "Sorszám" );
            table.Rows[0].Cells[1].Paragraphs[0].Append( "Név" );
            table.Rows[0].Cells[2].Paragraphs[0].Append( "Íjtípus" );
            table.Rows[0].Cells[3].Paragraphs[0].Append( "Kor" );
            table.Rows[0].Cells[4].Paragraphs[0].Append( "Egyesület" );
            table.Rows[0].Cells[5].Paragraphs[0].Append( "Csapat" );

            var rowIndex = 1;
            foreach( var indulo in induloAdatok.Indulok ) {
                table.Rows[rowIndex].Cells[0].Paragraphs[0].Append( indulo.Sorszam.ToString( ) );
                table.Rows[rowIndex].Cells[1].Paragraphs[0].Append( indulo.Nev );
                table.Rows[rowIndex].Cells[2].Paragraphs[0].Append( indulo.Ijtipus );
                table.Rows[rowIndex].Cells[3].Paragraphs[0].Append( ( indulo.Kor.ToString( ) ) );
                table.Rows[rowIndex].Cells[4].Paragraphs[0].Append( indulo.Egyesulet );
                table.Rows[rowIndex].Cells[5].Paragraphs[0].Append( indulo.Csapat.ToString( ) );
                rowIndex++;
            }

            #region Formazas
            table.Alignment = Alignment.center;

            Border b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
            Border c = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);

            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );

            for( int i = 0; i < 6; i++ ) {
                table.Rows[0].Cells[i].SetBorder( TableCellBorderType.Bottom, c );
            }

            foreach( var row in table.Rows ) {
                row.Cells[0].Width = 70;
                row.Cells[1].Width = 200;
                row.Cells[2].Width = 150;
                row.Cells[3].Width = 40;
                row.Cells[4].Width = 150;
                row.Cells[5].Width = 70;
            }

            table.AutoFit = AutoFit.ColumnWidth;
            #endregion
            document.InsertTable( table );
        }
コード例 #22
0
ファイル: CsapatLista.cs プロジェクト: belinyak/Ijasz2
        private void CsapatokTablazat( ) {
            foreach( var csapat in csapatok.csapatok ) {
                var table = document.AddTable( csapat.InduloAdatok.Indulok.Count + 1 , 6 );
                table.Alignment = Alignment.center;

                table.Rows[0].Cells[0].Paragraphs[0].Append( "Csapat" ).Bold( );
                table.Rows[0].Cells[1].Paragraphs[0].Append( "Sorszám" ).Bold( );
                table.Rows[0].Cells[2].Paragraphs[0].Append( "Név" ).Bold( );
                table.Rows[0].Cells[3].Paragraphs[0].Append( "Íjtípus" ).Bold( );
                table.Rows[0].Cells[4].Paragraphs[0].Append( "Kor" ).Bold( );
                table.Rows[0].Cells[5].Paragraphs[0].Append( "Egyesület" ).Bold( );

                var rowIndex = 1;
                foreach( var indulo in csapat.InduloAdatok.Indulok ) {
                    table.Rows[rowIndex - 1].Cells[0].Paragraphs[0].KeepWithNext( );
                    table.Rows[rowIndex - 1].Cells[1].Paragraphs[0].KeepWithNext( );
                    table.Rows[rowIndex - 1].Cells[2].Paragraphs[0].KeepWithNext( );
                    table.Rows[rowIndex - 1].Cells[3].Paragraphs[0].KeepWithNext( );
                    table.Rows[rowIndex - 1].Cells[4].Paragraphs[0].KeepWithNext( );
                    table.Rows[rowIndex - 1].Cells[5].Paragraphs[0].KeepWithNext( );

                    table.Rows[rowIndex].Cells[0].Paragraphs[0].Append( indulo.Csapat.ToString( ) );
                    table.Rows[rowIndex].Cells[1].Paragraphs[0].Append( indulo.Sorszam.ToString( ) );
                    table.Rows[rowIndex].Cells[2].Paragraphs[0].Append( indulo.Nev );
                    table.Rows[rowIndex].Cells[3].Paragraphs[0].Append( indulo.Ijtipus );
                    table.Rows[rowIndex].Cells[4].Paragraphs[0].Append( indulo.Kor.ToString( ) );
                    table.Rows[rowIndex].Cells[5].Paragraphs[0].Append( indulo.Egyesulet );

                    rowIndex++;
                }

                #region Formazas
                var b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
                var c = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);

                table.SetBorder( TableBorderType.InsideH, b );
                table.SetBorder( TableBorderType.InsideV, b );
                table.SetBorder( TableBorderType.Bottom, b );
                table.SetBorder( TableBorderType.Top, b );
                table.SetBorder( TableBorderType.Left, b );
                table.SetBorder( TableBorderType.Right, b );

                for( var i = 0; i < 6; i++ ) {
                    table.Rows[0].Cells[i].SetBorder( TableCellBorderType.Bottom, c );
                }

                foreach( var row in table.Rows ) {
                    row.Cells[0].Width = 57;
                    row.Cells[1].Width = 70;
                    row.Cells[2].Width = 160;
                    row.Cells[3].Width = 160;
                    row.Cells[4].Width = 70;
                    row.Cells[5].Width = 200;
                }
                table.AutoFit = AutoFit.ColumnWidth;
                #endregion

                document.InsertTable( table );
                if( csapat != csapatok.csapatok.Last( ) ) {
                    //document.InsertSectionPageBreak( );
                }
            }
        }
コード例 #23
0
 private void ExportWord()
 {
     if (Tables != null)
     {
         var columns = Columns;
         using (Docx.DocX doc = Docx.DocX.Create(FileName))
         {
             //表格的边框样式
             Docx.Border border = new Docx.Border();
             border.Tcbs = Docx.BorderStyle.Tcbs_single;
             int n = 0;
             foreach (TableEntity tableEntity in Tables)
             {
                 string tableId = tableEntity.ID.ToString();
                 //插入表名
                 Docx.Paragraph title = doc.InsertParagraph();
                 title.Append(tableEntity.TableName + "(" + tableEntity.Attr + ")");
                 title.Alignment = Docx.Alignment.center;
                 title.FontSize(15);
                 title.Bold();
                 title.SetLineSpacing(Docx.LineSpacingType.After, 1);
                 title.SetLineSpacing(Docx.LineSpacingType.Before, 1);
                 DataTable fields   = service.GetColumnDataTable(tableId);
                 int       rowCount = (fields == null ? 0 : fields.Rows.Count) + 1;
                 //计算表格多少行,多少列
                 Docx.Table table = doc.InsertTable(rowCount, columns.Count);
                 //先生成列头
                 Docx.Row colRow = table.Rows[0];
                 int      k      = 0;
                 foreach (string colKey in columns.Keys)
                 {
                     Docx.Cell colCell = colRow.Cells[k];
                     colCell.Paragraphs[0].Append(columns[colKey]).Alignment = Docx.Alignment.center;
                     colCell.SetBorder(Docx.TableCellBorderType.Top, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Left, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Right, border);
                     k++;
                 }
                 for (int i = 0; i < fields.Rows.Count; i++)
                 {
                     //一个属性为一行
                     Docx.Row row = table.Rows[i + 1];
                     //循环每列
                     int j = 0;
                     foreach (string key in columns.Keys)
                     {
                         Docx.Cell cell = row.Cells[j];
                         string    text = fields.Rows[i][key].ToString();
                         if (key == requiredKey)
                         {
                             text = text.ToLower() == "true" ? "是" : "";
                         }
                         cell.Paragraphs[0].Append(text).Alignment = Docx.Alignment.center;
                         cell.Paragraphs[0].FontSize(10);
                         cell.SetBorder(Docx.TableCellBorderType.Top, border);
                         cell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                         cell.SetBorder(Docx.TableCellBorderType.Left, border);
                         cell.SetBorder(Docx.TableCellBorderType.Right, border);
                         j++;
                     }
                 }
                 n++;
                 if (OnProgress != null)
                 {
                     OnProgress(this, new ProgressEventArgs()
                     {
                         Max = Tables.Count, Value = n
                     });
                 }
             }
             doc.Save();
         }
     }
 }