private void PrintToWord(WordNet._Document oDoc, string toPrint, int fontSize, int bold, string align = FCMWordAlign.LEFT) { WordNet.WdParagraphAlignment walign = WordNet.WdParagraphAlignment.wdAlignParagraphLeft; if (align == FCMWordAlign.CENTER) { walign = WordNet.WdParagraphAlignment.wdAlignParagraphCenter; } if (align == FCMWordAlign.RIGHT) { walign = WordNet.WdParagraphAlignment.wdAlignParagraphRight; } object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; WordNet.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref oRng); oPara.Range.Font.Name = "Arial"; oPara.Range.Font.Bold = bold; oPara.Range.Font.Size = fontSize; oPara.Range.Text = toPrint; oPara.Range.InsertParagraphAfter(); oPara.Alignment = walign; }
//设置固定行间距lineSpacing磅 public bool InsertText(string text, float fontsize, int fontbold, Word.WdParagraphAlignment align, int lineSpacing) { bool bRet = false; try { Word.Paragraph paragrah = m_WordDoc.Paragraphs.Add(ref missing); paragrah.Range.Text = text; paragrah.Range.Font.Size = fontsize; paragrah.Range.Font.Bold = fontbold; paragrah.Alignment = align; paragrah.LineSpacing = lineSpacing; //设置文档的行间距 paragrah.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceExactly; paragrah.Range.InsertParagraphAfter(); bRet = true; } catch (System.Exception) { bRet = false; } return(bRet); }
//插入文字 public bool InsertTextNewPage(string text, float fontsize, int fontbold, Word.WdParagraphAlignment align) { bool bRet = false; try { Word.Paragraph paragrah = m_WordDoc.Paragraphs.Add(ref missing); paragrah.Range.Text = text; paragrah.Range.Font.Size = fontsize; paragrah.Range.Font.Bold = fontbold; paragrah.Alignment = align; paragrah.Range.InsertParagraphAfter(); object pBreak = (int)Word.WdBreakType.wdSectionBreakNextPage; paragrah.Range.InsertBreak(ref pBreak); bRet = true; } catch (System.Exception) { bRet = false; } return(bRet); }
public void AddSimpleHeader(string HeaderText, Word.WdParagraphAlignment wdAlign) { //添加页眉 m_WordApp.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView; m_WordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader; m_WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText); m_WordApp.Selection.ParagraphFormat.Alignment = wdAlign;//设置左对齐 m_WordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekMainDocument; }
public void SetTableAlignment(MSWord.WdParagraphAlignment hAlign, MSWord.WdCellVerticalAlignment vAlign, int indTable = -1) { GetTableReference(indTable); m_pTable.Select(); MSWord.Selection sel = m_pApp.Selection; sel.Cells.VerticalAlignment = vAlign; sel.ParagraphFormat.Alignment = hAlign; }
public void AddPicHeader(string img, Word.WdParagraphAlignment align) { m_WordDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader; Word.InlineShape il = m_WordDoc.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture( img, ref missing, ref missing, ref missing); il.Width = 20; il.Height = 20; il.HorizontalLineFormat.Alignment = Word.WdHorizontalLineAlignment.wdHorizontalLineAlignRight; }
public void AddSimpleHeader(string HeaderText, Word.WdParagraphAlignment wdAlign, Word.WdColor fontcolor, float fontsize) { //添加页眉 m_WordApp.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView; m_WordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader; m_WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText); m_WordApp.Selection.Font.Color = fontcolor; //设置字体颜色 m_WordApp.Selection.Font.Size = fontsize; //设置字体大小 m_WordApp.Selection.ParagraphFormat.Alignment = wdAlign; //设置对齐方式 m_WordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekMainDocument; }
/// <summary> /// 插入文字 /// </summary> /// <param name="pText">文本信息</param> /// <param name="pFontSize">字体大小</param> /// <param name="pFontColor">字体颜色</param> /// <param name="pFontBold">字体粗体</param> /// <param name="ptextAlignment">方向</param> public void InsertText(string pText, int pFontSize, int pFontBold, string pFontName, MsWord.WdParagraphAlignment ptextAlignment, int newLineIndent) { //设置字体样式以及方向 this._wordApplication.Application.Selection.Font.Size = pFontSize; this._wordApplication.Application.Selection.Font.Bold = pFontBold; this._wordApplication.Application.Selection.Font.Name = pFontName; this._wordApplication.Application.Selection.ParagraphFormat.FirstLineIndent = newLineIndent; this._wordApplication.Application.Selection.ParagraphFormat.Alignment = ptextAlignment; this._wordApplication.Application.Selection.TypeText(pText); //this._wordDocument.Paragraphs.Last.Range.Text = pText; }
public bool InsertText(string text, float fontsize, int fontbold, Word.WdParagraphAlignment align, bool bCreateContentsPara) { bool bRet = false; bRet = InsertText(text, fontsize, fontbold, align); if (bCreateContentsPara) { m_ContentsPara = m_WordDoc.Paragraphs.Add(ref missing); } return(bRet); }
} // = new nhFont(); public tizhuStyle() { strCapLabelName = ""; capPos = WdCaptionPosition.wdCaptionPositionBelow; align = WdParagraphAlignment.wdAlignParagraphCenter; strPrefix = ""; strPostfix = ""; bGetHeadingText = false; bSnWhileSameHeadingText = false; bScopeAfterToc = false; Fnt = new nhFont(); ParaFmt = new nhParaFmt(); return; }
public void InsertPicture(string strFileName, MSWord.WdParagraphAlignment hAlign, string bookmark) { if (bookmark == "") { if (m_pDoc == null) { m_pDoc = m_pApp.ActiveDocument; } if (m_pDoc == null) { return; } m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } m_pSelection.Collapse(0); } else { m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } m_pSelection.GoTo(-1, Type.Missing, Type.Missing, bookmark); } MSWord.ParagraphFormat pParFormat = m_pSelection.ParagraphFormat; if (pParFormat == null) { return; } pParFormat.Alignment = hAlign; MSWord.InlineShapes shapes = m_pSelection.InlineShapes; if (shapes == null) { return; } shapes.AddPicture(strFileName, false, true); }
public void clone(tizhuStyle oth) { bEnable = oth.bEnable; strCapLabelName = oth.strCapLabelName; capPos = oth.capPos; align = oth.align; strPrefix = oth.strPrefix; strPostfix = oth.strPostfix; bGetHeadingText = oth.bGetHeadingText; bSnWhileSameHeadingText = oth.bSnWhileSameHeadingText; bScopeAfterToc = oth.bScopeAfterToc; Fnt.clone(oth.Fnt); ParaFmt.clone(oth.ParaFmt); return; }
private void Pregunta27() { p1 = "INCORRECTO"; string textPdf = obtenerTextoDePdf(); string cadenaAchequear1 = "(iteración) \n \nTodos"; string cadenaAchequear2 = "(iteración) \nTodos"; //(iteración) \n \nTodos //(iteración) \nTodos if (textPdf.Contains(cadenaAchequear1) || textPdf.Contains(cadenaAchequear2)) { // var temp = docAlumno.Content.Text.IndexOf("todos los fractales tienen algo en común"); int start = docAlumno.Content.Text.IndexOf("Todos los fractales tienen algo en común") - 15; int end = docAlumno.Content.Text.IndexOf("Todos los fractales tienen algo en común") + 25; Word.Range range = docAlumno.Range(Start: start, End: end); var negrita = Math.Abs(range.Font.Bold); var cursiva = Math.Abs(range.Font.Italic); int tamaño = Convert.ToInt32(range.Font.Size); //22 Word.WdParagraphAlignment alineacion = range.Paragraphs.Alignment; //wdAlignParagraphLeft Word.WdCharacterCase tipo = range.Case; //wdTitleSentence string cadenaAchequear3 = "wdAlignParagraphLeft"; string cadenaAchequear4 = "wdTitleSentence"; string contenidoDeArchivo1 = alineacion.ToString(); string contenidoDeArchivo2 = tipo.ToString(); if (contenidoDeArchivo1.Contains(cadenaAchequear3) && contenidoDeArchivo2.Contains(cadenaAchequear4) && tamaño == 22 && negrita == 1 && cursiva == 1) { p1 = "CORRECTO"; } } GuardarPuntaje(); CerrarWords(); BorrarPreguntasTemporales(); }
public void SetText(string strText, MSWord.WdParagraphAlignment hAlignment, FontParams font = null) { if (m_pSelection == null) { if (m_pDoc == null) { m_pDoc = m_pApp.ActiveDocument; } if (m_pApp == null) { return; } m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } } object varInfo = m_pSelection.get_Information(MSWord.WdInformation.wdWithInTable); if (Convert.ToBoolean(varInfo) == true) { m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } m_pSelection.Collapse(0); } MSWord.ParagraphFormat pf = m_pSelection.ParagraphFormat; pf.Alignment = hAlignment; m_pSelection.Text = strText; if (font != null) { PutFont(font, m_pSelection); } m_pSelection.Collapse(0); }
public WordSelection(MSWord.Range inputRange, bool insertParagrAfterText, bool setDefaultStyle) { _range = inputRange; _insertParagrAfterText = insertParagrAfterText; if (setDefaultStyle) { _savedAligment = _range.ParagraphFormat.Alignment; _range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft; _savedAligment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft; _range.Italic = 0; _range.Bold = 0; } else { _savedAligment = _range.ParagraphFormat.Alignment; } }
public Word.Table InsertTable(Word.WdParagraphAlignment align, int rows, int cols, bool bInsertNewPage) { Word.Table table = null; Word.Paragraph paragraph = m_WordDoc.Paragraphs.Add(ref missing); paragraph.Alignment = align; object start = 0; object end = 0; table = m_WordDoc.Tables.Add(paragraph.Range, rows, cols, ref missing, ref missing); if (bInsertNewPage) { object pBreak = (int)Word.WdBreakType.wdSectionBreakNextPage; paragraph.Range.InsertBreak(ref pBreak); } return(table); }
public void SetCellsAlignment(int iCol1, int iCol2, int iRow1, int iRow2, MSWord.WdParagraphAlignment hAlign, MSWord.WdCellVerticalAlignment vAlign, int indTable = -1) { GetTableReference(indTable); MSWord.Cell pCell1 = m_pTable.Cell(iRow1, iCol1); if (pCell1 == null) { return; } MSWord.Cell pCell2 = m_pTable.Cell(iRow2, iCol2); if (pCell2 == null) { return; } MSWord.Range r = m_pDoc.Range(pCell1.Range.Start, pCell2.Range.End); r.Select(); MSWord.Selection sel = m_pApp.Selection; sel.ParagraphFormat.Alignment = hAlign; sel.Cells.VerticalAlignment = vAlign; }
public bool InsertText(string text, string heading, Word.WdParagraphAlignment align) { bool bRet = false; try { Word.Paragraph paragrah = m_WordDoc.Paragraphs.Add(ref missing); paragrah.Range.Text = text; object obj = heading; paragrah.set_Style(ref obj); paragrah.Alignment = align; paragrah.Range.InsertParagraphAfter(); bRet = true; } catch (System.Exception) { bRet = false; } return(bRet); }
public bool InsertText(string text, float fontsize, int fontbold, Word.WdParagraphAlignment align) { bool bRet = false; try { Word.Paragraph paragrah = m_WordDoc.Paragraphs.Add(ref missing); paragrah.Range.Text = text; paragrah.Range.Font.Size = fontsize; paragrah.Range.Font.Bold = fontbold; paragrah.Alignment = align; paragrah.Range.InsertParagraphAfter(); bRet = true; } catch (System.Exception) { bRet = false; } return(bRet); }
public bool InsertPicture(string img, int width, int height, Word.WdParagraphAlignment align) { bool bRet = false; try { Word.Paragraph paragraph = m_WordDoc.Paragraphs.Add(ref missing); paragraph.Alignment = align; object range = paragraph.Range; Word.InlineShape il = paragraph.Range.InlineShapes.AddPicture(img, ref missing, ref missing, ref range); il.Width = width; il.Height = height; paragraph.Range.InsertParagraphAfter(); bRet = true; } catch (System.Exception) { bRet = false; } return(bRet); }
/// <summary> /// 插入文字 /// </summary> /// <param name="pText">文本信息</param> /// <param name="pFontSize">字体大小</param> /// <param name="pFontColor">字体颜色</param> /// <param name="pFontBold">字体粗体</param> /// <param name="ptextAlignment">方向</param> public void InsertText(string pText, int pFontSize, Microsoft.Office.Interop.Word.WdColor pFontColor, int pFontBold, Microsoft.Office.Interop.Word.WdParagraphAlignment ptextAlignment) { //设置字体样式以及方向 this._wordApplication.Application.Selection.Font.Size = pFontSize; this._wordApplication.Application.Selection.Font.Bold = pFontBold; this._wordApplication.Application.Selection.Font.Color = pFontColor; this._wordApplication.Application.Selection.ParagraphFormat.Alignment = ptextAlignment; this._wordApplication.Application.Selection.TypeText(pText); }
protected void SetFontCell(Word.Cell cell, Word.WdParagraphAlignment aligment, int bold) { cell.Range.ParagraphFormat.Alignment = aligment; cell.Range.Font.Bold = bold; cell.Range.Font.Name = "Times New Roman"; }
private void InsertText(String Text, int bold, int size, Word.WdUnderline underline, Word.WdParagraphAlignment alignment, bool Enter) { Word.Paragraph Para1; objRangePara = adoc.Bookmarks.get_Item(ref oEndOfDoc).Range; Para1 = adoc.Content.Paragraphs.Add(ref objRangePara); Para1.Range.Text = Text; Para1.Range.Bold = bold; Para1.Range.Font.Size = size; Para1.Range.Font.Underline = underline; Para1.Alignment = alignment; if (Enter) { rangeEndOfFile = adoc.Bookmarks.get_Item(ref oEndOfDoc).Range; Word.Table tableLessons = adoc.Tables.Add(rangeEndOfFile, 1, 1); } }
//Set the style of words, adding size, bold, fontcolor and alignment public void InsertFormatText(string context, int fontSize, Word.WdColor fontColor, int fontBold, string familyName, Word.WdParagraphAlignment align) { wordApp.Application.Selection.Font.Size = fontSize; wordApp.Application.Selection.Font.Bold = fontBold; wordApp.Application.Selection.Font.Color = fontColor; wordApp.Selection.Font.Name = familyName; wordApp.Application.Selection.ParagraphFormat.Alignment = align; wordApp.Application.Selection.TypeText(context); }
public void SetFontSizeCellTable(int indexTable, int rows, int cell, string font, int size, int bold, int italic, Word.WdUnderline underline, Word.WdParagraphAlignment alignment) { try { Word.Range rng = doc.Tables[indexTable].Range.Rows[rows].Cells[cell].Range; rng.Font.Size = size; rng.Font.Name = font; rng.Font.Bold = bold; rng.Font.Italic = italic; rng.Font.Underline = underline; rng.ParagraphFormat.Alignment = alignment; } catch { } }
//在书签处插入值 /// <summary> /// 在标签处插入值 /// </summary> /// <param name="bookmark">标签</param> /// <param name="value">字段</param> /// <param name="pFontSize">字体大小</param> /// <param name="pFontColor">字体颜色</param> /// <param name="pFontBold">字体粗体</param> /// <param name="ptextAlignment">字体方向</param> /// <returns></returns> public bool InsertValue(string bookmark, string value, int pFontSize, Microsoft.Office.Interop.Word.WdColor pFontColor, int pFontBold, Microsoft.Office.Interop.Word.WdParagraphAlignment ptextAlignment) { object bkObj = bookmark; if (wordApp.ActiveDocument.Bookmarks.Exists(bookmark)) { wordApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Select(); wordApp.Selection.Font.Size = pFontSize; wordApp.Selection.Font.Color = pFontColor; wordApp.Selection.Font.Bold = pFontBold; wordApp.Selection.ParagraphFormat.Alignment = ptextAlignment; wordApp.Selection.TypeText(value); return(true); } return(false); }
private void SetStyleOfTable(Word.Table table, int column, int cell, int bold, int size, Word.WdParagraphAlignment alignH) { //table.Columns[column].Cells[cell].Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; //table.Columns[column].Cells[cell].VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; //table.Columns[column].Cells[cell].Range.Font.Size = 11; table.Cell(cell, column).Range.ParagraphFormat.Alignment = alignH; table.Cell(cell, column).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; table.Cell(cell, column).Range.Font.Size = size; table.Cell(cell, column).Range.Font.Bold = bold; }