Пример #1
0
        public void generateWork(Invoce.Entity.Invoce invoce)
        {
            XWPFDocument doc   = new XWPFDocument();
            XWPFTable    table = doc.CreateTable(11, 1);

            table.SetLeftBorder(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            table.SetRightBorder(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            table.SetTopBorder(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");


            XWPFTableCell cellFIO          = table.GetRow(0).GetCell(0);
            XWPFTableCell cellStreetBuild  = table.GetRow(1).GetCell(0);
            XWPFTableCell cellCityAndIndex = table.GetRow(2).GetCell(0);
            XWPFTableCell cellCountry      = table.GetRow(3).GetCell(0);
            XWPFTableCell cellEmail        = table.GetRow(4).GetCell(0);
            XWPFTableCell cellNumber       = table.GetRow(5).GetCell(0);
            XWPFTableCell cellDescription  = table.GetRow(6).GetCell(0);
            XWPFTableCell cellRaid         = table.GetRow(7).GetCell(0);
            XWPFTableCell cellSignature    = table.GetRow(8).GetCell(0);
            XWPFTableCell cellHelper       = table.GetRow(9).GetCell(0);
            XWPFTableCell cellFIOEnd       = table.GetRow(10).GetCell(0);



            cellFIO.SetText(invoce.GetFIO());
            cellStreetBuild.SetText(invoce.GetStreetBuild());
            cellCityAndIndex.SetText(invoce.GetCityAndIndex());
            cellCountry.SetText(invoce.GetCountry());
            cellEmail.SetText(invoce.GetEmail());
            cellNumber.SetText("+" + invoce.GetTelephoneNumber());
            cellDescription.SetText(invoce.GetDescription());
            cellRaid.SetText(invoce.GetRaid());
            cellSignature.SetText(invoce.GetSignature());
            cellHelper.SetText("Signature                          Data");
            cellFIOEnd.SetText(invoce.GetFIO());

            cellFIO.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");///Убирает нижний бордер
            cellStreetBuild.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellCityAndIndex.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellCountry.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellEmail.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellNumber.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellRaid.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellSignature.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellFIOEnd.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellDescription.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            cellHelper.SetBorderBottom(XWPFBorderType.SINGLE, 3, 3, "#FFFFFF");
            XWPFParagraph p1 = cellRaid.AddParagraph();
            //XSSFCellStyle raidStyle = (HSSFCellStyle)table.CreateCellStyle();//don't use doc.CreateParagraph
            //XWPFRun r1 = p1.CreateRun();
            //cellRaid.



            //r1.SetText("This is test table contents");

            //r1.FontFamily = "Courier";
            //r1.SetUnderline(UnderlinePatterns.DotDotDash);
            //r1.SetTextPosition(100);
            //r1.set
            //r1.SetColor("FF0000");

            //table.GetRow(2).GetCell(2).SetText("only text");

            FileStream out1 = new FileStream(
                this._wordFile.GetWritePath(),
                FileMode.Create
                );

            doc.Write(out1);
            out1.Close();
        }