InsertRow() public method

Insert a row at the end of this table.
public InsertRow ( ) : Row
return Row
コード例 #1
0
        private void AddRowWithReplacements(Table tbl, RollsheetPersonInfo m, int orgId)
        {
            var row = tbl.InsertRow(docx.Tables[0].Rows[0]);

            tbl.Rows.Add(row);
            var dict = replacements.DocXReplacementsDictionary(m.Person, orgId);

            foreach (var p in row.Paragraphs.Where(vv => vv.Text.HasValue()))
            {
                if (dict.Keys.Any(vv => p.Text.Contains(vv)))
                {
                    foreach (var d in dict)
                    {
                        if (p.Text.Contains(d.Key))
                        {
                            if (d.Key == "{barcodepeopleid}")
                            {
                                var s   = BarCodeStream(m.Person.PeopleId.ToString(), 40, showtext: false);
                                var img = curr.AddImage(s);
                                p.AppendPicture(img.CreatePicture());
                                p.ReplaceText(d.Key, "");
                            }
                            else if (d.Key.Equal("{MLG}"))
                            {
                                p.ReplaceText(d.Key, m.MemberTypeCode);
                            }
                            else if (d.Key.Equal("{highlight}"))
                            {
                                if (m.Highlight.HasValue())
                                {
                                    p.ReplaceText(d.Key, m.Highlight);
                                }
                                else
                                {
                                    p.Remove(false);
                                }
                            }
                            else if (d.Key.Equal("{altname}"))
                            {
                                p.ReplaceText(d.Key, m.UseAltName ? m.Person.AltName : "");
                            }
                            else if (d.Key.Equal("{name}"))
                            {
                                p.ReplaceText(d.Key, m.Person.Name2);
                                if (m.MemberTypeCode == "VS")
                                {
                                    row.Cells.Last().Shading = Color.FromArgb(226, 239, 217); // light green
                                }
                            }
                            else
                            {
                                p.ReplaceText(d.Key, d.Value);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void ExportWordTable()
        {
            List <SINHVIENEntities> lstSINHVIEN = dapSINHVIEN.GetAll();

            if (lstSINHVIEN != null)
            {
                //Khai báo đường dẫn của file sau khi lưu
                string urlFileSave = "/AppFile/tmp/ListSV.docx";
                urlFileSave = Server.MapPath(urlFileSave);
                //Khai báo đường dẫn của file doc được đọc
                string fileName = Server.MapPath("/AppFile/Docs/ExportWordTable.docx");

                using (DocX doc = DocX.Load(fileName))
                {
                    Novacode.Table tblSINHVIEN = doc.Tables[1];
                    Novacode.Row   rowCn       = tblSINHVIEN.Rows[1];
                    int            count       = 2;
                    Novacode.Row   newRow;

                    for (int i = 0; i < lstSINHVIEN.Count; i++)
                    {
                        newRow = tblSINHVIEN.InsertRow(rowCn, count++);
                        newRow.Cells[0].ReplaceText("@stt", (i + 1).ToString());
                        newRow.Cells[1].ReplaceText("@hovaten", lstSINHVIEN[i].HOVATEN == null ? "" : lstSINHVIEN[i].HOVATEN);
                        newRow.Cells[2].ReplaceText("@ngaysinh", lstSINHVIEN[i].NGAYSINH == null ? "" : lstSINHVIEN[i].NGAYSINH.ToString("dd/MM/yyyy"));
                        newRow.Cells[3].ReplaceText("@gioitinh", lstSINHVIEN[i].GIOITINH == 1 ? "Nam" : "Nữ");
                        newRow.Cells[4].ReplaceText("@diachi", lstSINHVIEN[i].DIACHI == null ? "" : lstSINHVIEN[i].DIACHI);
                        newRow.Cells[5].ReplaceText("@sdt", lstSINHVIEN[i].SDT == null ? "" : lstSINHVIEN[i].SDT);
                        newRow.Cells[6].ReplaceText("@email", lstSINHVIEN[i].EMAIL == null ? "" : lstSINHVIEN[i].EMAIL);
                        newRow.Cells[7].ReplaceText("@lop", lstSINHVIEN[i].TENLOP);
                    }
                    tblSINHVIEN.RemoveRow(1);
                    doc.SaveAs(urlFileSave);
                    doc.Save();
                    Response.Buffer  = true;
                    Response.Expires = 0;
                    Response.Clear();
                    string strHttpContext_ContentType = "application/msword";
                    HttpContext.Current.Response.ContentType     = strHttpContext_ContentType;
                    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
                    HttpContext.Current.Response.Charset         = "utf-8";
                    Response.AddHeader("Content-Disposition", "attachment; filename=BangThongTinSinhVien" + ".docx");
                    Response.TransmitFile(urlFileSave);
                    Response.Flush();
                    Response.Close();
                    Response.End();
                }
            }
        }
コード例 #3
0
        private void PopulateTable(Table table, IEnumerable<ProtocolResult> data)
        {
            var textStyle = new Formatting();
            textStyle.Size = 9;
            textStyle.FontFamily = new System.Drawing.FontFamily("Times New Roman");

            int productIndex = 1;
            string lastProductName = "";

            foreach (var item in data)
            {
                var row = table.InsertRow();

                if (lastProductName != item.ProductTest.Product.Name)
                {
                    row.Cells[0].Paragraphs[0].InsertText(productIndex + ".", false, textStyle);
                    productIndex++;
                    lastProductName = item.ProductTest.Product.Name;
                }

                row.Cells[1].Paragraphs[0].InsertText(item.ResultNumber, false, textStyle);
                row.Cells[2].Paragraphs[0].InsertText(item.ProductTest.Product.Name, false, textStyle);
                row.Cells[3].Paragraphs[0].InsertText(item.ProductTest.Test.Name, false, textStyle);
                row.Cells[4].Paragraphs[0].InsertText(item.ProductTest.Test.UnitName, false, textStyle);
                row.Cells[5].Paragraphs[0].InsertText(item.ProductTest.TestMethod.Method, false, textStyle);
                row.Cells[6].Paragraphs[0].InsertText(item.Results, false, textStyle);
                row.Cells[7].Paragraphs[0].InsertText(item.ProductTest.MethodValue, false, textStyle);
                row.Cells[8].Paragraphs[0].InsertText(item.ProductTest.Test.Temperature, false, textStyle);
                //rowIndex++;
            }
        }
コード例 #4
0
        private void btnAsinar_Click(object sender, RoutedEventArgs e)
        {
            List <int> Seleccionados = new List <int>();
            bool       revCM = false, revDev = false, revPPQA = false;

            foreach (Contenido item in lstCM.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revCM = true;
                }
            }
            foreach (Contenido item in lstDev.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revDev = true;
                }
            }
            foreach (Contenido item in lstPPQA.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revPPQA = true;
                }
            }
            if (!revCM)
            {
                MessageBox.Show("Debes seleccionar un CM");
                return;
            }
            if (!revDev)
            {
                MessageBox.Show("Debes seleccionar un Desarrollador");
                return;
            }
            if (!revPPQA)
            {
                MessageBox.Show("Debes seleccionar un PPQA");
                return;
            }
            Service1Client cliente  = new Service1Client();
            int            idTicket = int.Parse(lblTicket.Content.ToString());
            bool           correcto = cliente.AsignaPersonal(idTicket, Seleccionados.ToArray(), Seguridad.Seguridad.saltkey);

            if (!correcto)
            {
                MessageBox.Show("Error al guardar información");
                return;
            }
            UsuarioFirmado UsuFirmado = (UsuarioFirmado)Application.Current.Resources["UserFirmado"];
            SolicitudPPQA  Solicitud  = cliente.GetSolicitudPPQA(idTicket, Seguridad.Seguridad.saltkey);

            UsuariosInvolucrados[] Usuarios = cliente.GetInvolucrados(idTicket, Seguridad.Seguridad.saltkey);
            string NombreDocumento          = "KSDP_PPQA_F04_AsignaciónRecursos.docx";
            string Ruta = System.AppDomain.CurrentDomain.BaseDirectory;

            Ruta += "Documentos/" + NombreDocumento;
            CreaEstructura CCrea        = new CreaEstructura();
            UsuarioSVN     usuSVNRuta   = cliente.GetRuta(idTicket, UsuFirmado.IdEmpleado, Seguridad.Seguridad.saltkey);
            UsuarioSVN     usuSVNContra = cliente.ObtenerUsuarioSVN(UsuFirmado.IdEmpleado, Seguridad.Seguridad.saltkey);
            string         RutaSVN      = CCrea.Inicio(usuSVNRuta.RutaLocal);

            using (var documento = DocX.Load(Ruta))
            {
                documento.ReplaceText("@cliente", Solicitud.cliente);
                documento.ReplaceText("@app", Solicitud.app);
                documento.ReplaceText("@identificador", Solicitud.identificador);
                documento.ReplaceText("@fecha", DateTime.Now.ToShortDateString());
                documento.ReplaceText("@nombrepro", Solicitud.nombrepro);
                documento.ReplaceText("@descpro", Solicitud.descripcion);
                documento.ReplaceText("@lider", Solicitud.Lider);
                Novacode.Table myTable = documento.Tables[0];
                foreach (UsuariosInvolucrados usu in Usuarios)
                {
                    Row myRow = myTable.InsertRow();
                    myRow.Cells[0].Paragraphs.First().Append(usu.Nombre);
                    myRow.Cells[1].Paragraphs.First().Append(usu.Puesto);
                    myRow.Cells[2].Paragraphs.First().Append(usu.Iniciales);
                    myRow.Cells[3].Paragraphs.First().Append(usu.Funciones);
                    myTable.Rows.Add(myRow);
                }
                documento.SaveAs(RutaSVN + "/" + NombreDocumento);
            }
            MessageBox.Show("Se agrego correctamente el documento");
        }
コード例 #5
0
        private void InsertTableNumerationRow(Table table)
        {
            var textStyle = new Formatting();
            textStyle.Size = 9;
            textStyle.Bold = true;
            textStyle.FontFamily = new System.Drawing.FontFamily("Times New Roman");

            var row = table.InsertRow();

            for (int i = 0; i < table.ColumnCount; i++)
            {
                row.Cells[i].Paragraphs[0].InsertText((i + 1).ToString(), false, textStyle);
            }
        }