private void ReemplazarDatos(Word.Range rng_datos, string[] aDatos) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = aDatos[0];// "Nombre Profesional"; ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = aDatos[1];// "123456789Z"; ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = aDatos[2];// "GERENTE"; ExecuteReplace(fnd); fnd.Text = "{fnacim}"; fnd.Replacement.Text = aDatos[3];// "15/02/1973"; ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); ExecuteReplace(fnd); //TableRow theRow = theTable.Elements<TableRow>().Last(); //Word.Row oLastRow = newDocument.Bookmarks["Tabla01"].Range.Tables[1].Rows.Last; // Word.Row oLastRow = rng_datos.Tables[1].Rows.Last; rng_datos.Tables[1].Rows.Add(); rng_datos.Tables[1].Rows.Last.Cells[1].Select(); wordApplication.Selection.TypeText("Texto en la primera celda"); rng_datos.Tables[1].Rows.Last.Cells[2].Select(); wordApplication.Selection.TypeText("Texto en la segunda celda"); rng_datos.Tables[1].Rows.Last.Cells[3].Select(); wordApplication.Selection.TypeText("Texto en la tercera celda"); //oLastRow //TableRow rowCopy = (TableRow)theRow.CloneNode(true); //rowCopy.Descendants<TableCell>().ElementAt(0).Append(new Paragraph(new Run(new Text(order.Contact.ToString())))); //rowCopy.Descendants<TableCell>().ElementAt(1).Append(new Paragraph(new Run(new Text(order.NameOfProduct.ToString())))); //rowCopy.Descendants<TableCell>().ElementAt(2).Append(new Paragraph(new Run(new Text(order.Amount.ToString())))); //theTable.AppendChild(rowCopy); //Word.Range rowrng = oLastRow.Range; //rowrng.Copy(); }
private void CargarDatosPersonales(Word.Range rng_datos, DataRow oFila) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = oFila["Profesional"].ToString(); ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = oFila["t001_cip"].ToString(); ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = oFila["t035_descripcion"].ToString(); ExecuteReplace(fnd); fnd.Text = "{fnacimiento}"; fnd.Replacement.Text = ((DateTime)oFila["t001_fecnacim"]).ToShortDateString(); ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); bool bHayFoto = false; if (oFila["t001_foto"] != DBNull.Value) { bHayFoto = true; //sPathDocs SUPER.Capa_Negocio.Utilidades.ByteArrayToFile(sPathDocs + "..\\temp\\foto.jpg", (byte[])oFila["t001_foto"]); } if (bHayFoto) { Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); //currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); currentSelection.InlineShapes.AddPicture(sPathDocs + "..\\temp\\foto.jpg"); System.IO.File.Delete(sPathDocs + "..\\temp\\foto.jpg"); } ExecuteReplace(fnd); }
private void CargarDatosPersonales(Word.Range rng_datos, string[] aDatos) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = aDatos[0];// "Nombre Profesional"; ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = aDatos[1];// "123456789Z"; ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = aDatos[2];// "GERENTE"; ExecuteReplace(fnd); fnd.Text = "{fnacimiento}"; fnd.Replacement.Text = aDatos[3];// "15/02/1973"; ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); ExecuteReplace(fnd); }