Ejemplo n.º 1
0
        /// <summary>
        /// 创建表,用来展示平面图(Plan)的表。
        /// </summary>
        /// <returns></returns>
        public static Table PlanTable(DocX document, int CompanyID, int parcelId, int buildingId, List <string> lstStr)
        {
            Table t = null;
            int   i = 0;

            try
            {
                if (lstStr.Count == 0)
                {
                    t = document.AddTable(1, 1);
                }
                else
                {
                    t = document.AddTable(lstStr.Count, 1);
                    foreach (string s in lstStr)
                    {
                        Picture p = picture.picHelper.getPic(document, PathManager.getSingleton().GetPlanpicPath(buildingId, s, false), 287, 670);
                        if (p == null)
                        {
                            continue;
                        }

                        t.Rows[i].Cells[0].Paragraphs.First().AppendPicture(p).AppendLine(s).FontSize(16).Bold().Alignment = Alignment.center;
                        t.Rows[i].Cells[0].VerticalAlignment = VerticalAlignment.Center;
                        t.Rows[i++].Cells[0].Width           = 23.27;
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteLog(typeof(tableHelper), ex);
            }

            return(t);
        }
Ejemplo n.º 2
0
        public static void CreateTestReport(Patient patient, MedicalTest test, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            Type test_type = test.GetType();

            using (DocX document = DocX.Create(file_path))
            {
                Novacode.Paragraph header = document.InsertParagraph(
                    //selected_procedure.ProcedureType.First().ToString().ToUpper() + String.Join("", selected_procedure.ProcedureType.Skip(1)).ToLower(),
                    test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                    false,
                    new Formatting()
                {
                    FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                    Size       = 16D
                }
                    );
                header.Alignment = Alignment.center;
                header.Bold();
                document.InsertParagraph(" ");
                Novacode.Table patient_info = document.AddTable(5, 2);
                patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                    patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                    ", " + patient.City + ", " + patient.Address
                    );
                patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                patient_info.Alignment = Alignment.left;
                patient_info.AutoFit   = AutoFit.Window;
                PropertyInfo[] indicators = test_type.GetProperties().Where(x => x.IsDefined(typeof(TestInfo))).ToArray();
                Novacode.Table test_info  = document.AddTable(indicators.Count(), 2);
                int            k          = 0;
                foreach (var indicator in indicators)
                {
                    test_info.Rows[k].Cells[0].Paragraphs.First().Append(indicator.GetCustomAttribute <TestInfo>().DisplayName);
                    object property_value = indicator.GetValue(test);
                    test_info.Rows[k].Cells[1].Paragraphs.First().Append(property_value != null ? property_value.ToString() : "");
                    k++;
                }
                test_info.Alignment = Alignment.left;
                test_info.AutoFit   = AutoFit.Window;
                document.InsertTable(patient_info);
                document.InsertParagraph(" ");
                document.InsertTable(test_info);
                document.Save();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void InsertSummaryResults()
        {
            try
            {
                Table table = resultSummarydocument.AddTable(1, 4);
                // Specify some properties for this Table.
                table.Alignment = Alignment.left;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;
                table.SetColumnWidth(0, 667.87);
                table.SetColumnWidth(1, 5347.87);
                table.SetColumnWidth(2, 1255.87);
                table.SetColumnWidth(3, 1825.82);

                table.Rows[0].Cells[0].Paragraphs.First().Append(smrw.ToString() + ".");
                smrw += 1;
                table.Rows[0].Cells[1].Paragraphs.First().Append(BaseUtilities.scenarioName);
                switch (BaseUtilities.scenarioStatus.ToLower())
                {
                case "pass":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Pass").Color(System.Drawing.Color.FromArgb(52, 168, 83));
                    break;

                case "fail":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Fail").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;

                case "skip":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Skip").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;
                }


                Hyperlink link = resultSummarydocument.AddHyperlink("Click here", new Uri(reportpath));
                table.Rows[0].Cells[3].Paragraphs.First().AppendHyperlink(link).Color(System.Drawing.Color.FromArgb(1, 91, 168));

                resultSummarydocument.InsertTable(table);

                resultSummarydocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Ejemplo n.º 4
0
        private void FillPurchases(DocX doc)
        {
            IEnumerable <LBCFUBL_WCF.DBO.Purchase> purchases = Helper
                                                               .GetPurchaseClient()
                                                               .GetPurchases()
                                                               .OrderBy(x => x.date)
                                                               .OrderBy(x => x.login)
                                                               .ThenBy(x => x.Product.name)
                                                               .Where(x => x.date >= from && x.date <= to);

            Novacode.Table table = doc.AddTable(purchases.Count() + 1, 4);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Append("Login").Bold();
            table.Rows[0].Cells[1].InsertParagraph().Append("Date").Bold();
            table.Rows[0].Cells[2].InsertParagraph().Append("Produit").Bold();
            table.Rows[0].Cells[3].InsertParagraph().Append("Prix").Bold();

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Purchase purchase in purchases)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(purchase.login);
                table.Rows[i].Cells[1].InsertParagraph().Append(purchase.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[2].InsertParagraph().Append(purchase.Product.name);
                table.Rows[i].Cells[3].InsertParagraph().Append(currency(purchase.Product.cost_with_margin));
                i++;
            }

            doc.InsertTable(table);
        }
Ejemplo n.º 5
0
        private void FillAccounts(DocX doc)
        {
            IEnumerable <LBCFUBL_WCF.DBO.Account> accounts = Helper
                                                             .GetAccountClient()
                                                             .GetAccounts()
                                                             .OrderBy(x => x.login)
                                                             .Where(x => x.date >= from && x.date <= to);

            Novacode.Table table = doc.AddTable(accounts.Count() + 1, 3);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Append("Login").Bold();
            table.Rows[0].Cells[1].InsertParagraph().Append("Date").Bold();
            table.Rows[0].Cells[2].InsertParagraph().Append("Argent").Bold();

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Account account in accounts)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(account.login);
                table.Rows[i].Cells[1].InsertParagraph().Append(account.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[2].InsertParagraph().Append(currency(account.argent));
                i++;
            }

            doc.InsertTable(table);
        }
Ejemplo n.º 6
0
        public void TableWithMultipleMergeRight()
        {
            using (var doc = new DocX())
            {
                doc.Create();

                var table = doc.AddTable(9);

                var row = table.AddRow();
                row.HeaderRow = true;

                for (int i = 0; i < 9; i++)
                {
                    row.Cells[i].SetBoldText((i + 1).ToString());
                }

                row           = table.AddRow();
                row.HeaderRow = true;

                // this should merge cells 2, 3 and 4
                row.Cells[1].MergeRight = 2;

                // this should merge cells 5 and 6
                row.Cells[4].MergeRight = 1;

                row.SetBoldText(1, "Test1", Align.Center);
                row.SetBoldText(4, "Test2", Align.Center);

                row.Underline(1, 4);

                Validate(doc);

                doc.Close();
            }
        }
Ejemplo n.º 7
0
        public void TableWithHeaderRow()
        {
            using (var doc = new DocX())
            {
                doc.Create();

                var table = doc.AddTable(5);

                for (int i = 0; i < 50; i++)
                {
                    var row = table.AddRow();
                    row.SetBorders(Units.HalfPt, BorderValue.Single);

                    if (i == 0)
                    {
                        // shade the first row and set as a header
                        row.SetShading("E7E6E6");

                        row.HeaderRow = true;
                    }

                    for (int j = 0; j < 5; j++)
                    {
                        row.Cells[j].Paragraphs[0].Append($"Cell {(j + 1)}");
                    }
                }

                Validate(doc);

                doc.Close();
            }
        }
Ejemplo n.º 8
0
        public void TableWidthsTwips()
        {
            using (var doc = new DocX())
            {
                doc.Create();

                var col1 = Units.InchToTwips(3.9).ToString();
                var col2 = Units.InchToTwips(1.3).ToString();

                var table = doc.AddTable(3, col1, col2, col2);

                for (int i = 0; i < 3; i++)
                {
                    var row = table.AddRow();
                    row.SetBorders(Units.HalfPt, BorderValue.Single);

                    if (i == 0)
                    {
                        row.SetShading(ShadingPattern.Clear, "E7E6E6");

                        row.HeaderRow = true;
                    }

                    for (int j = 0; j < 3; j++)
                    {
                        row.Cells[j].Paragraphs[0].Append($"Cell {(j + 1)}");
                    }
                }

                Validate(doc);

                doc.Close();
            }
        }
Ejemplo n.º 9
0
        public void TableWidthsCM()
        {
            using (var doc = new DocX())
            {
                doc.Create();

                var table = doc.AddTable(3, "9.906cm", "3.302cm", "3.302cm");

                for (int i = 0; i < 3; i++)
                {
                    var row = table.AddRow();
                    row.SetBorders(Units.HalfPt, BorderValue.Single);

                    if (i == 0)
                    {
                        row.SetShading(ShadingPattern.Clear, "E7E6E6");

                        row.HeaderRow = true;
                    }

                    for (int j = 0; j < 3; j++)
                    {
                        row.Cells[j].Paragraphs[0].Append($"Cell {(j + 1)}");
                    }
                }

                Validate(doc);

                doc.Close();
            }
        }
Ejemplo n.º 10
0
        private void ExportarDgvAWord(DataGridView dgv, string filename)
        {
            //Creamos el Word
            DocX miWord = DocX.Create(filename);

            //Creamos la tabla
            //Le sumo + 1 para adicionarle el encabezado
            Table miTabla = miWord.AddTable(dgv.RowCount + 1, dgv.ColumnCount);

            miWord.InsertParagraph("Hello Word");

            for (int fila = -1; fila < dgv.RowCount; fila++)
            {
                for (int col = 0; col < dgv.ColumnCount; col++)
                {
                    if (fila == -1) //Es encabezado
                    {
                        //Mediante Bold() cambio a negrita toda la fila
                        miTabla.Rows[0].Cells[col].Paragraphs.First().Append(dgv.Columns[col].HeaderText).Bold();
                    }
                    else //Es otra fila
                    {
                        miTabla.Rows[fila + 1].Cells[col].Paragraphs.First().Append(dgv.Rows[fila].Cells[col].Value.ToString());
                    }
                }
            }

            miWord.InsertTable(miTabla);
            miWord.Save();
        }
Ejemplo n.º 11
0
        private void AddTable(CalculationResult calculationResult)
        {
            PageBreak();
            var value = $@"Расчетный состав для {MainWindowViewModel.Instance.Calculation.CountConcrete} м³";

            AddTitle(value);

            var table = _document.AddTable(5, 2);

            table.Design    = TableDesign.TableGrid;
            table.Alignment = Alignment.center;
            table.SetColumnWidth(0, 5024);
            table.SetColumnWidth(1, 5024);

            table.Rows[0].Cells[0].Paragraphs[0].Append("Цемент").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[0].Cells[1].Paragraphs[0].Append($@"{calculationResult.CorrectedCementConsumption * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[1].Cells[0].Paragraphs[0].Append("Вода").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[1].Cells[1].Paragraphs[0].Append($@"{calculationResult.WaterFlowWithRegardToAirContent * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} л.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[2].Cells[0].Paragraphs[0].Append("Песок").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[2].Cells[1].Paragraphs[0].Append($@"{calculationResult.TheAmountOfSandDry * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[3].Cells[0].Paragraphs[0].Append("Крупный заполнитель").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[3].Cells[1].Paragraphs[0].Append($@"{calculationResult.NumberOfCoarseAggregate * MainWindowViewModel.Instance.Calculation.CountConcrete: .##}  кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[4].Cells[0].Paragraphs[0].Append($@"Химическая добавка { MainWindowViewModel.Instance.Calculation.Admixtures.Name}").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[4].Cells[1].Paragraphs[0].Append($@"{calculationResult.ChemicalAdditive * MainWindowViewModel.Instance.Calculation.CountConcrete: .##}  кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);
            _document.InsertTable(table);
        }
Ejemplo n.º 12
0
        private Table GenerateWordsTable(DocX document, IEnumerable <string> selectedWords)
        {
            var rowCount = (int)Math.Ceiling(selectedWords.Count() / 5.0);
            var table    = document.AddTable(rowCount, 5);

            table.SetDirection(Direction.RightToLeft);

            int row = 0;
            int col = 0;

            foreach (var word in GetEncodedWords(selectedWords))
            {
                table.Rows[row].Cells[col].Paragraphs[0].Append(word);

                col++;

                if (col == 5)
                {
                    col = 0;
                    row++;
                }
            }

            return(table);
        }
Ejemplo n.º 13
0
        public ActionResult Aircrafts()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("/Account/Login"));
            }
            IEnumerable <Base> bases = db.Bases;

            using (MemoryStream ms = new MemoryStream())
            {
                DocX document = DocX.Create(ms);
                document.SetDefaultFont(new Xceed.Document.NET.Font("Times New Roman"), 12);
                document.MarginLeft   = 85;
                document.MarginTop    = 56.7f;
                document.MarginBottom = 56.7f;
                document.MarginRight  = 42.5f;

                document.InsertParagraph("Розподілення яхт за портами\n").Bold().Alignment = Alignment.center;
                foreach (Base airbase in bases)
                {
                    IEnumerable <Aircraft> aircrafts = db.Aircrafts.Include(m => m.Base).Where(m => m.BaseId == airbase.Id);
                    if (aircrafts.Count() == 0)
                    {
                        continue;
                    }
                    document.InsertParagraph($"Індекс: {airbase.PostIndex}").Alignment = Alignment.center;
                    document.InsertParagraph($"Місто: {airbase.City}").Alignment       = Alignment.center;
                    document.InsertParagraph($"Адреса: {airbase.Adress}").Alignment    = Alignment.center;
                    Table table = document.AddTable(aircrafts.Count() + 1, 6);
                    table.Alignment = Alignment.center;
                    table.Design    = TableDesign.TableGrid;
                    string[] names = { "Реєстраційний номер", "Виробник", "Модель", "Клас", "Рік виробництва", "Статус" };
                    for (int k = 0; k < names.Length; ++k)
                    {
                        table.Rows[0].Cells[k].Paragraphs[0].Append(names[k]).Bold().Alignment = Alignment.center;
                    }
                    int j = 0;
                    foreach (Aircraft aircraft in aircrafts)
                    {
                        table.Rows[j + 1].Cells[0].Paragraphs[0].Append(aircraft.RegistrationNumber).Alignment = Alignment.center;
                        table.Rows[j + 1].Cells[1].Paragraphs[0].Append(aircraft.Manufacturer).Alignment       = Alignment.center;
                        table.Rows[j + 1].Cells[2].Paragraphs[0].Append(aircraft.Model).Alignment = Alignment.center;
                        table.Rows[j + 1].Cells[3].Paragraphs[0].Append(aircraft.Class).Alignment = Alignment.center;
                        table.Rows[j + 1].Cells[4].Paragraphs[0].Append(aircraft.YearOfProduction.ToString()).Alignment = Alignment.center;
                        table.Rows[j + 1].Cells[5].Paragraphs[0].Append(aircraft.Status).Alignment = Alignment.center;
                        j++;
                    }
                    document.InsertParagraph().InsertTableAfterSelf(table);
                    document.InsertParagraph();
                }
                document.InsertParagraph($"\n\n\n Дата формування: {DateTime.Now}").Alignment = Alignment.right;
                document.Save();

                Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                Response.AddHeader("content-disposition",
                                   "attachment;filename=Aircrafts.docx");
                Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
            }
            return(null);
        }
Ejemplo n.º 14
0
        private static Table CreateMainData(DocX doc, string documentType, Vendor vendor, Customer customer, Consumer consumer, DocumentData documentData, PaymentData paymentData)
        {
            var t = doc.AddTable(1, 2);

            t.SetWidthsPercentage(new[] { 50f, 50f }, doc.PageWidth);
            var border = new Border();

            border.Tcbs = BorderStyle.Tcbs_none;
            for (int i = 0; i < 2; i++)
            {
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Left, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Top, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Right, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Bottom, border);
            }

            GenerateVendorText(t.Rows[0].Cells[0], vendor);
            GenerateCustomerText(t.Rows[0].Cells[0], customer);
            if (consumer != null)
            {
                GenerateConsumerText(t.Rows[0].Cells[0], consumer);
            }

            GenerateDocumentDataText(t.Rows[0].Cells[1], documentData, documentType);
            GeneratePaymentDataText(t.Rows[0].Cells[1], paymentData);
            doc.InsertTable(t);

            return(t);
        }
Ejemplo n.º 15
0
        private void экспортВWordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.Filter       = "Word file (*.docx)|*.docx";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK && sfd.FileName != "")
            {
                if (Path.GetExtension(sfd.FileName) == ".docx")
                {
                    DocX      doc = DocX.Create(sfd.FileName);
                    Paragraph p1  = doc.InsertParagraph();
                    p1.AppendLine("Подробный тепловой расчет ступеней паровой турбины").FontSize(14);
                    p1.AppendLine();
                    Table t = doc.AddTable(j, 3);
                    t.Alignment = Alignment.center;
                    t.SetColumnWidth(0, 200);
                    t.Rows[0].Cells[0].Paragraphs.First().Append("Величина").FontSize(12);
                    t.Rows[0].Cells[1].Paragraphs.First().Append("Единица измерения").FontSize(12);
                    t.Rows[0].Cells[2].Paragraphs.First().Append("Значение").FontSize(12);
                    for (int i = 1; i < j; i++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            t.Rows[i].Cells[k].Paragraphs.First().Append("" + (String)DB.Rows[i].Cells[k].Value);
                        }
                    }
                    doc.InsertTable(t);
                    doc.Save();
                }
            }
        }
Ejemplo n.º 16
0
        private void InsertExperiences(Resume resume, DocX doc)
        {
            // 3 experience
            doc.InsertParagraph().AppendLine();
            doc.InsertParagraph(_localizationService.GetResource("Resume.Fields.Experiences", _workContext.Current.WorkingLanguage.Id), false, H2);
            //.AppendLine(line);

            foreach (var exp in resume.Experiences.OrderBy(x => x.DisplayOrder))
            {
                // doc.InsertParagraph().AppendLine();

                var table = doc.AddTable(5, 2);
                table.Design  = TableDesign.TableNormal;
                table.AutoFit = AutoFit.Contents;

                InsertExperienceRow(doc, table, 0, "Resume.Fields.Experiences.Name", exp.GetLocalized(x => x.Name), H4);
                InsertExperienceRow(doc, table, 1, "Resume.Fields.Experiences.Period", exp.GetLocalized(x => x.Period));
                InsertExperienceRow(doc, table, 2, "Resume.Fields.Experiences.Function", exp.GetLocalized(x => x.Function));
                InsertExperienceRow(doc, table, 3, "Resume.Fields.Experiences.City", exp.GetLocalized(x => x.City));
                InsertExperienceRow(doc, table, 4, "Resume.Fields.Experiences.Tasks", exp.GetLocalized(x => x.Tasks));

                doc.InsertTable(table);

                //foreach (var p in exp.Projects)
                //{
                //    doc.InsertParagraph().AppendLine();
                //    doc.InsertParagraph(p.GetLocalized(x => x.Name), false, H4);
                //    doc.InsertParagraph(p.GetLocalized(x => x.Description), false, Normal);
                //    doc.InsertParagraph(p.GetLocalized(x => x.Technology), false, Normal);
                //}
            }
        }
Ejemplo n.º 17
0
        private static Table CreateSignTable(DocX doc)
        {
            var t = doc.AddTable(1, 2);

            t.SetWidthsPercentage(new[] { 50f, 50f }, doc.PageWidth);
            var border = new Border();

            border.Tcbs = BorderStyle.Tcbs_none;

            var formattingBold = new Formatting {
                Bold = true, Size = DefaultSize, FontFamily = Font
            };
            var formattingWithoutBold = new Formatting {
                Bold = false, Size = DefaultSize, FontFamily = Font
            };

            for (int i = 0; i < 2; i++)
            {
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Left, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Top, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Right, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Bottom, border);
            }

            var p = t.Rows[0].Cells[0].Paragraphs.First().Append($"........................................................................\r\n{Resource.customerSign}", formattingWithoutBold);

            p.Alignment = Alignment.center;

            p           = t.Rows[0].Cells[1].Paragraphs.First().Append($"........................................................................\r\n{Resource.vendorSign}", formattingWithoutBold);
            p.Alignment = Alignment.center;

            doc.InsertTable(t);
            return(t);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Crea la tabla de recursos valiosos
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="empresa"></param>
        private void insertarRecursosValiosos(DocX doc, Empresa empresa)
        {
            List <RecursoValioso> listadoRecursoValioso = MatrizBO.ConsultarRecursosValiosos(empresa.IdEmpresa);
            int cantidadRecursos = listadoRecursoValioso.Count;
            var RVParrafo        = new Novacode.Formatting();

            RVParrafo.FontFamily = new System.Drawing.FontFamily("Calibri");
            RVParrafo.Size       = 12D;
            RVParrafo.Position   = 3;

            Paragraph pParr = doc.InsertParagraph("En este sentido se identifican " + cantidadRecursos + " recursos por encima del promedio, los cuales se convierten en valiosos y se listan a continuación", false, RVParrafo);

            pParr.Alignment = Alignment.left;

            Table tab = doc.AddTable(cantidadRecursos + 1, 2);

            tab.AutoFit   = AutoFit.Contents;
            tab.Alignment = Alignment.center;
            tab.Design    = TableDesign.ColorfulGridAccent1;
            tab.Rows[0].Cells[0].Paragraphs.First().Append("Recurso Valioso");
            tab.Rows[0].Cells[0].Paragraphs.First().Alignment = Alignment.center;
            tab.Rows[0].Cells[0].Paragraphs.First().Bold();
            tab.Rows[0].Cells[1].Paragraphs.First().Append("Observaciones");
            tab.Rows[0].Cells[1].Paragraphs.First().Alignment = Alignment.center;
            tab.Rows[0].Cells[1].Paragraphs.First().Bold();

            for (int i = 0; i < cantidadRecursos; i++)
            {
                RecursoValioso recursoValioso = listadoRecursoValioso[i];
                tab.Rows[i + 1].Cells[0].Paragraphs.First().Append(recursoValioso.NombreRecurso);
            }
            doc.InsertTable(tab);
        }
Ejemplo n.º 19
0
        private DocX outputDoc(string nowBalance, string nowSum, string nowBalanceAfterBuy, string nowBonus)
        {
            string pathDocument = "C:\\Users\\oobit\\Desktop\\first.docx";
            DocX   document     = DocX.Create(pathDocument);

            document.MarginLeft   = 60.0f;
            document.MarginRight  = 60.0f;
            document.MarginTop    = 60.0f;
            document.MarginBottom = 60.0f;
            document.InsertParagraph("Чек покупки").Bold().Font("Times New Roman").FontSize(14);
            Table table = document.AddTable(4, 2);

            table.Alignment = Alignment.center;
            table.Design    = TableDesign.TableGrid;
            table.SetWidths(new float[] { 180.0f, 600.0f });
            table.Rows[0].Cells[0].Paragraphs[0].Append("Баланс до покупки").Font("Times New Roman").FontSize(12).Bold();
            table.Rows[0].Cells[1].Paragraphs[0].Append(nowBalance).Font("Times New Roman").FontSize(12);
            table.Rows[1].Cells[0].Paragraphs[0].Append("Сумма").Font("Times New Roman").FontSize(12).Bold();
            table.Rows[1].Cells[1].Paragraphs[0].Append(nowSum).Font("Times New Roman").FontSize(12);
            table.Rows[2].Cells[0].Paragraphs[0].Append("Баланс после покупки").Font("Times New Roman").FontSize(12).Bold();
            table.Rows[2].Cells[1].Paragraphs[0].Append(nowBalanceAfterBuy).Font("Times New Roman").FontSize(12);
            table.Rows[3].Cells[0].Paragraphs[0].Append("Текущее количество бонусов").Font("Times New Roman").FontSize(12).Bold();
            table.Rows[3].Cells[1].Paragraphs[0].Append(nowBonus).Font("Times New Roman").FontSize(12);
            document.InsertParagraph().InsertTableAfterSelf(table);
            document.Save();
            return(document);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 创建市公司的组织结构表
        /// </summary>
        /// <param name="document"></param>
        /// <param name="childCompanies"></param>
        /// <param name="picPath"></param>
        /// <returns></returns>
        public static Table organizationTable(DocX document, List <Companymodel> childCompanies, string picPath)
        {
            if (childCompanies.Count == 0)
            {
                return(null);
            }

            Table t = document.AddTable(childCompanies.Count + 1, 2);


            int i = 0;

            foreach (Companymodel cm in childCompanies)
            {
                if (i % 2 == 0)
                {
                    t.Rows[i].Cells[0].FillColor = Color.Blue;
                }
                else
                {
                    t.Rows[i].Cells[0].FillColor = Color.LightBlue;
                }
                t.Rows[i].Cells[0].Paragraphs.First().Append(cm.name).FontSize(15).Bold().Alignment = Alignment.center;
                t.Rows[i++].Cells[0].VerticalAlignment = VerticalAlignment.Center;
            }
            t.MergeCellsInColumn(1, 0, childCompanies.Count);
            Picture p = picture.picHelper.getPic(document, picPath, 728, 525);

            if (p != null)
            {
                t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(p).Alignment = Alignment.center;//插入组织结构图
                t.Rows[0].Cells[1].VerticalAlignment = VerticalAlignment.Center;
            }
            return(t);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 添加用于放置鸟瞰图的表格
        /// </summary>
        /// <param name="document"></param>
        /// <param name="p_Orth"></param>
        /// <param name="p_front"></param>
        /// <param name="p_rear"></param>
        /// <param name="p_left"></param>
        /// <param name="p_right"></param>
        /// <returns></returns>
        public static Table AerialviewpicTable(DocX document, Picture p_Orth, Picture p_front, Picture p_rear, Picture p_left, Picture p_right)
        {
            Table t = null;

            try
            {
                t = document.AddTable(3, 2);

                t.Rows[0].Cells[0].Paragraphs.First().AppendPicture(p_Orth).Alignment  = Alignment.center; //正射
                t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(p_front).Alignment = Alignment.center; //前
                t.Rows[1].Cells[0].Paragraphs.First().AppendPicture(p_rear).Alignment  = Alignment.center; //后
                t.Rows[1].Cells[1].Paragraphs.First().AppendPicture(p_left).Alignment  = Alignment.center; //左
                t.Rows[2].Cells[0].Paragraphs.First().AppendPicture(p_right).Alignment = Alignment.center; //右

                t.Rows[0].Cells[0].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[0].Cells[1].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[1].Cells[0].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[1].Cells[1].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[2].Cells[0].VerticalAlignment = VerticalAlignment.Center;
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteLog(typeof(tableHelper), ex);
            }
            return(t);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 创建“省公司”的企业用房分析表(前两行)
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static Table Template_province_analysis(DocX document)
        {
            Table t = null;

            try
            {
                t = document.AddTable(2, 4);

                #region "前两行"
                t.Rows[0].Cells[0].Paragraphs.First().Append("序号").Bold().Alignment       = Alignment.center;
                t.Rows[0].Cells[1].Paragraphs.First().Append("单位").Bold().Alignment       = Alignment.center;
                t.Rows[0].Cells[2].Paragraphs.First().Append("统计项目名称").Bold().Alignment   = Alignment.center;
                t.Rows[0].Cells[3].Paragraphs.First().Append("建筑面积(m2)").Bold().Alignment = Alignment.center;

                t.Rows[0].Cells[0].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[0].Cells[1].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[0].Cells[2].VerticalAlignment = VerticalAlignment.Center;
                t.Rows[0].Cells[3].VerticalAlignment = VerticalAlignment.Center;

                #endregion
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteLog(typeof(tableHelper), ex);
            }
            return(t);
        }
Ejemplo n.º 23
0
        public static void GerarTabelaAreaDeEstagio(this DocX document, List <AreaEstagioCurso> areas, int IdArea)
        {
            int   rows = areas.Count();
            Table t    = document.AddTable(rows, 2);

            Formatting format = new Formatting();

            format.Bold = true;
            t.Paragraphs.ForEach(x => x.FontSize(12));
            t.Paragraphs.ForEach(x => x.Font("Arial"));
            t.Alignment = Alignment.center;
            t.AutoFit   = AutoFit.ColumnWidth;
            for (int i = 0; i <= (int)TableBorderType.InsideV; i++)
            {
                t.SetBorder((TableBorderType)i, new Border());
            }

            for (int i = 1; i <= rows; i++)
            {
                int pos = i - 1;
                if (i % 7 == 0)
                {
                    document.InsertSectionPageBreak();
                }

                t.Rows[pos].Cells[1].Paragraphs[0].InsertText(areas[pos].Nome);
                if (areas[pos].Identificador == IdArea)
                {
                    t.Rows[pos].Cells[0].Paragraphs[0].InsertText("X", false, format);
                }
            }

            document.InsertTable(t);
        }
        private void button13_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.Filter       = "Word file (*.docx)|*.docx";
            if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName != "")
            {
                if (Path.GetExtension(sfd.FileName) == ".docx")
                {
                    DocX      doc = DocX.Create(sfd.FileName);
                    Paragraph p1  = doc.InsertParagraph();
                    p1.AppendLine("Итоговые результаты расчета").FontSize(14);
                    p1.AppendLine();
                    Table t = doc.AddTable(P.Z + 2, 5);
                    t.Alignment = Alignment.center;
                    t.Rows[0].Cells[0].Paragraphs.First().Append("№ ступени:").FontSize(12);
                    t.Rows[0].Cells[1].Paragraphs.First().Append("H0, кДж / кг").FontSize(12);
                    t.Rows[0].Cells[2].Paragraphs.First().Append("G, кг/с").FontSize(12);
                    t.Rows[0].Cells[3].Paragraphs.First().Append("\u03b7oi").FontSize(12);
                    t.Rows[0].Cells[4].Paragraphs.First().Append("N, МВт").FontSize(12);
                    for (int i = 0; i <= P.Z; i++)
                    {
                        for (int k = 0; k < 5; k++)
                        {
                            t.Rows[i + 1].Cells[k].Paragraphs.First().Append("" + (String)dataGridView1.Rows[i].Cells[k].Value);
                        }
                    }
                    doc.InsertTable(t);
                    doc.Save();
                }
            }
        }
Ejemplo n.º 25
0
        // Create Issue Description doc for Evidence (SIT)
        public void CreateXLSX()
        {
            string fp = filepath;

            fp += release + " – Evidence.docx";
            using (DocX document = DocX.Create(@fp)) {
                // Add document info
                string title = release + " – Evidence";
                document.InsertParagraph(title).FontSize(15d).Bold().SpacingAfter(50d).Alignment = Alignment.center;

                // Add a Table into the document and sets its values
                var t1 = document.AddTable(test_names.Count, 2);
                t1.Design    = TableDesign.TableGrid;
                t1.Alignment = Alignment.center;
                t1.Rows[0].Cells[0].FillColor = Color.LightGray;
                t1.Rows[0].Cells[1].FillColor = Color.LightGray;

                for (int i = 0; i < test_names.Count; i++)
                {
                    if (i == 0)
                    {
                        t1.Rows[i].Cells[0].Paragraphs[0].Append(test_names[i]).FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment        = Alignment.center;
                        t1.Rows[i].Cells[1].Paragraphs[0].Append(test_descriptions[i]).FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment = Alignment.center;
                    }
                    else
                    {
                        t1.Rows[i].Cells[0].Paragraphs[0].Append(test_names[i]).FontSize(8d).KeepLinesTogether(true);
                        t1.Rows[i].Cells[1].Paragraphs[0].Append(test_descriptions[i]).FontSize(8d).KeepLinesTogether(true);
                    }
                }

                t1.AutoFit = AutoFit.Contents;
                document.InsertTable(t1);
                Paragraph p = document.InsertParagraph("\n");

                // Create new table where .zip is embedded
                var t2 = document.AddTable(2, 1);
                t2.Design    = TableDesign.TableGrid;
                t2.Alignment = Alignment.center;
                t2.Rows[0].Cells[0].FillColor = Color.LightGray;
                t2.Rows[0].Cells[0].Paragraphs[0].Append("Before/After Evidence").FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment = Alignment.center;
                t2.Rows[1].Cells[0].Paragraphs[0].FontSize(8d).Alignment = Alignment.center;
                document.InsertTable(t2);

                document.Save();
            }
        }
Ejemplo n.º 26
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = "report";
            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var conn = new MySqlConnection(Data.connString);

            conn.Open();

            var currentDate  = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            var monthAgoDate = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd hh:mm:ss");

            DocX document = DocX.Create(saveFileDialog1.FileName);

            document.InsertParagraph("Отчет").Font("Times New Roman").FontSize(18)
            .Alignment = Alignment.center;
            document.InsertParagraph();

            var countSuccesses =
                conn.QueryFirst <string> (
                    $"select count(*) from link_archive where created between '{monthAgoDate}' and '{currentDate}'");

            document.InsertParagraph($"За последний месяц было создано {countSuccesses} пар");
            document.InsertParagraph();

            var couplesList = conn.Query <forMeeting> (
                $"select concat_ws(' ', A.firstname, A.lastname) as first_person, concat_ws(' ', B.firstname, B.lastname) as second_person from link_archive\njoin archive_person as A on A.id = link_archive.firstP_id\njoin archive_person as B on B.id = link_archive.secondP_id\nwhere created between '{monthAgoDate}' and '{currentDate}'").ToList();

            Table couplesTable = document.AddTable(couplesList.Count + 1, 2);

            couplesTable.Alignment = Alignment.both;
            couplesTable.AutoFit   = AutoFit.ColumnWidth;
            couplesTable.SetWidthsPercentage(new[] { 50.0f, 50.0f });
            couplesTable.Design = TableDesign.TableGrid;

            couplesTable.Rows[0].Cells[0].Paragraphs[0].Append("Первый партнер");
            couplesTable.Rows[0].Cells[1].Paragraphs[0].Append("Второй партнер");

            for (int i = 0; i < couplesList.Count; i++)
            {
                couplesTable.Rows[i + 1].Cells[0].Paragraphs[0].Append(couplesList[i].first_person);
                couplesTable.Rows[i + 1].Cells[1].Paragraphs[0].Append(couplesList[i].second_person);
            }

            document.InsertTable(couplesTable);
            document.InsertParagraph();

            var declinedCount = conn.QueryFirst <string> ($"select count(*) from archive_person\nwhere archive_person.id not in (select id from person) and archive_person.id not in (select firstP_id from link_archive where created between '{monthAgoDate}' and '{currentDate}') and archive_person.id not in (select secondP_id from link_archive where created between '{monthAgoDate}' and '{currentDate}')");

            document.InsertParagraph($"От услуг отказалось {declinedCount} клиентов");

            document.Save();
            conn.Close();

            Process.Start(saveFileDialog1.FileName);
        }
Ejemplo n.º 27
0
        private void button1_Click(object sender, EventArgs e)
        {
            //创建文档
            using (DocX document = DocX.Create(@"HelloWorld.docx"))
            {
                //插入段落
                Paragraph p = document.InsertParagraph();

                //段落加入文本,定义格式
                p.Append("Hello World!")              //内容
                .Font(new Xceed.Words.NET.Font("宋体")) //字体格式
                .FontSize(20)                         //字体大小
                .Color(Color.Blue)                    //字体颜色
                .Bold()
                .Alignment = Alignment.center;        //字体对其方式

                p = document.InsertParagraph();       //创建段落
                p.Append("CHINA")
                .Font(new Xceed.Words.NET.Font("微软雅黑"))
                .FontSize(18)
                .Color(Color.Red);

                //插入表格4x4,使用addtable后再inserttable
                var table1 = document.AddTable(9, 4);
                table1.Design = TableDesign.TableGrid;

                for (int i = 0; i < 9; i++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        table1.Rows[i].Cells[k].Paragraphs.First().InsertText(string.Format("第{0}行,第{1}列", i, k));
                    }
                }
                //合并单元格
                table1.MergeCellsInColumn(0, 0, 1);
                //////水平合并(合并第1行的第1、2个单元格)
                //table1.ApplyHorizontalMerge(0, 0, 1);
                //table1.Rows[0].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[0].Cells[1].Paragraphs[0].ChildObjects[0]);

                ////垂直合并(合并第1列的第3、4个单元格)
                //table.ApplyVerticalMerge(0,2, 3);
                //table.Rows[2].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[3].Cells[0].Paragraphs[0].ChildObjects[0]);


                document.InsertTable(table1);

                //追加行
                document.Tables[0].InsertRow().Cells[1].Paragraphs.First().InsertText("新添11加的行");
                //插入图片
                p = document.InsertParagraph();
                Xceed.Words.NET.Image image = document.AddImage(@"1.jpg");
                Picture pic = image.CreatePicture();
                p.InsertPicture(pic);
                p.Alignment = Alignment.right;
                //保存文档
                document.Save();
            }
            MessageBox.Show("Done!");
        }
Ejemplo n.º 28
0
        public static void AppendTabelaCarimbo(this DocX document)
        {
            Table t = document.AddTable(1, 1);

            t.Design    = TableDesign.TableNormal;
            t.Alignment = Alignment.center;
            t.Rows[0].Cells[0].InsertParagraph("Carimbo do CNPJ").SpacingBefore(10d).SpacingAfter(25d);
        }
Ejemplo n.º 29
0
        public void ThreeByThreeTable()
        {
            using (var doc = new DocX())
            {
                doc.Create();

                var table = doc.AddTable(3);

                var row = table.AddRow();
                row.HeaderRow = true;

                row.Cells[0].Paragraphs[0].Append("Cell 1");
                row.Cells[1].Paragraphs[0].Append("Cell 2").SetAlignment(Align.Center);
                row.Cells[2].Paragraphs[0].Append("Cell 3").SetAlignment(Align.Right);

                row.Cells[0].Borders.Set(Units.HalfPt, BorderValue.Single);

                row.SetShading(ShadingPattern.Clear, "E7E6E6");

                row = table.AddRow();

                row.SetBorders(Units.HalfPt, BorderValue.Single);

                row.Cells[0].Paragraphs[0].Append("Cell 1");
                row.Cells[1].Paragraphs[0].Append("Cell 2").SetAlignment(Align.Center);
                row.Cells[2].Paragraphs[0].Append("Cell 3").SetAlignment(Align.Right);

                row = table.AddRow();

                row.Cells[0].Paragraphs[0].Append("Cell 1");
                row.Cells[1].Paragraphs[0].Append("Cell 2").SetAlignment(Align.Center);
                row.Cells[2].Paragraphs[0].Append("Cell 3").SetAlignment(Align.Right);

                row.Cells[1].Shading.Set(ShadingPattern.Clear, "F2F2F2");
                row.Cells[2].Shading.Set(ShadingPattern.Clear, "auto");

                var rows = table.Rows.ToList();

                for (int i = 0; i < rows.Count(); i++)
                {
                    row = rows[i];

                    row.Height           = Units.UHalfInch;
                    row.BreakAcrossPages = true;

                    for (int j = 0; j < row.Cells.Count(); j++)
                    {
                        var cell = row.Cells[j];

                        cell.SetVerticalAlignment(TableVerticalAlignment.Center);
                    }
                }

                Validate(doc);

                doc.Close();
            }
        }
Ejemplo n.º 30
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var companybik = Interaction.InputBox("Введите БИК компании: ");

            if (companybik == "")
            {
                return;
            }

            saveFileDialog1.FileName = "list";
            saveFileDialog1.ShowDialog();
            var path = saveFileDialog1.FileName;

            var conn = new MySqlConnection(Information.connString);

            conn.Open();

            DocX document = DocX.Create(path);

            document.InsertParagraph("Список должностей").Font("Times New Roman").FontSize(18).Alignment = Alignment.left;
            document.InsertParagraph();

            var count        = conn.QueryFirst <string> ($"select count(*) from position where company_id = {companybik}");
            var positionList = conn.Query <Position> ($"select name, payment, conditions, requirements from position where company_id = {companybik}").ToList();

            Table mainTable = document.AddTable(Convert.ToInt32(count) + 1, 4);

            mainTable.Alignment = Alignment.both;
            mainTable.AutoFit   = AutoFit.ColumnWidth;
            mainTable.SetWidthsPercentage(new[] { 25.0f, 25.0f, 25.0f, 25.0f });
            mainTable.Design = TableDesign.None;

            mainTable.Rows[0].Cells[0].Paragraphs[0].Append("Название должнолсти");
            mainTable.Rows[0].Cells[1].Paragraphs[0].Append("Оплата");
            mainTable.Rows[0].Cells[2].Paragraphs[0].Append("Условия");
            mainTable.Rows[0].Cells[3].Paragraphs[0].Append("Требования");

            for (int i = 0; i < Convert.ToInt32(count); i++)
            {
                mainTable.Rows[i + 1].Cells[0].Paragraphs[0].Append(positionList[i].name);
                mainTable.Rows[i + 1].Cells[1].Paragraphs[0].Append(positionList[i].payment);
                mainTable.Rows[i + 1].Cells[2].Paragraphs[0].Append(positionList[i].conditions);
                mainTable.Rows[i + 1].Cells[3].Paragraphs[0].Append(positionList[i].requirements);
            }

            document.InsertTable(mainTable);

            document.InsertParagraph();
            var phone = conn.QueryFirstOrDefault <string> ($"select phone from company where bik = {companybik}");

            document.InsertParagraph($"Звонить по телефону {phone}");

            document.Save();
            conn.Close();

            Process.Start(path);
        }