public void SetTextInCell(int Column, int Row, string strText, int indTable = -1, string strDefault = "", bool bAdd = false) { if (strText == "") { strText = strDefault; if (strText == "") { return; } } int top = 1; int left = 1; //MSWord.Columns pCols = null; //MSWord.Rows pRows = null; MSWord.Cell pCell = null; MSWord.Selection pSel = null; GetTableReference(indTable); //pCols = m_pTable.Columns; //if (pCols == null) return; //pRows = m_pTable.Rows; //if (pRows == null) return; if (Column >= 0) { left = Column; } if (Row >= 0) { top = Row; } // проверяем правильность установки границ диапазона // получаем верхнюю левую ячейку диапазона pCell = m_pTable.Cell(top, left); if (pCell == null) { return; } if (!bAdd) { pCell.Range.Text = strText; } else { pCell.Select(); pSel = m_pApp.Selection; pSel.EndKey(); pSel.Text = strText; pSel.Collapse(0); } }
public void SplitCell(int Column, int FirstRow, int LastRow, int iCntCols, int iCntRows, int indTable = -1) { GetTableReference(indTable); for (int i = FirstRow; i <= LastRow; i++) { MSWord.Cell pCellBegin = m_pTable.Cell(i, Column); pCellBegin.Select(); m_pApp.Selection.Cells.Split(iCntRows, iCntCols, false); } }
public void DeleteColumnEx(int Column, int indTable) { GetTableReference(indTable); MSWord.Cell pCell = m_pTable.Cell(1, Column); pCell.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } //m_pSelection.MoveDown(MSWord.WdUnits.wdLine, 2); m_pSelection.Columns.Delete(); }
public void DeleteRowEx(int Row, int indTable = -1) { GetTableReference(indTable); MSWord.Cell pCell = m_pTable.Cell(Row, 1); pCell.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } //m_pSelection.MoveDown(MSWord.WdUnits.wdLine, 2); m_pSelection.Rows.Delete(); }
public void SetCellList(int iCol, int iRow, int indTable) { GetTableReference(indTable); MSWord.Cell pCell = m_pTable.Cell(iRow, iCol); if (pCell == null) { return; } pCell.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } m_pApp.ListGalleries[MSWord.WdListGalleryType.wdBulletGallery].ListTemplates[1].ListLevels[1].NumberFormat = "-"; m_pSelection.Range.ListFormat.ApplyListTemplateWithLevel(m_pApp.ListGalleries[MSWord.WdListGalleryType.wdBulletGallery].ListTemplates[1], false, MSWord.WdListApplyTo.wdListApplyToWholeList, MSWord.WdDefaultListBehavior.wdWord10ListBehavior); }
public void SetCellColor(int iCol, int iRow, MSWord.WdColor color, MSWord.WdColor text_color = MSWord.WdColor.wdColorAutomatic, int indTable = -1) { if (text_color == MSWord.WdColor.wdColorAutomatic && color == MSWord.WdColor.wdColorAutomatic) { return; } GetTableReference(indTable); MSWord.Cell pCell = m_pTable.Cell(iRow, iCol); if (pCell == null) { return; } pCell.Select(); MSWord.Selection sel = m_pApp.Selection; sel.Shading.Texture = MSWord.WdTextureIndex.wdTextureNone; sel.Shading.ForegroundPatternColor = MSWord.WdColor.wdColorAutomatic; sel.Shading.BackgroundPatternColor = color; if (text_color != MSWord.WdColor.wdColorAutomatic) { sel.Font.Color = text_color; } }