Стоит посмотреть
Вертикальное объединение ячеек в MS Word
Сохранить в файлеОбсудить в форуме
Описание
Данный пример демонстрирует объединение ячеек в Word по вертикали.
Текст примера
Import rcw; ms = CreateObject ("rsax","TRsAxServer","RsAxServer",IsStandAlone()); wrd = ms.CreateComObject ("Word.Application", False); wrd.WindowState=1; wrd.Documents.add; wrd.ActiveWindow.View=1; wrd.selection.PageSetup.Orientation = 0; wrd.selection.PageSetup.LeftMargin = 45; wrd.selection.TypeParagraph; wrd.selection.TypeParagraph; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Bold=1; wrd.Selection.Font.Size=14; wrd.Selection.TypeText("Ведомость по состоянию на "+String({curdate}:f)); wrd.selection.TypeParagraph; wrd.selection.TypeParagraph; range=wrd.selection.Range; wrd.ActiveDocument.Tables.Add(range,1,5); wrd.Selection.Tables(1).Borders.InsideLineStyle = True; wrd.Selection.Tables(1).Borders.OutsideLineStyle = True; wrd.Selection.Tables(1).Columns(1).Width = 100; wrd.Selection.Tables(1).Columns(2).Width = 100; wrd.Selection.Tables(1).Columns(3).Width = 100; wrd.Selection.Tables(1).Columns(4).Width = 80; wrd.Selection.Tables(1).Columns(5).Width = 20; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("Наименование клиента, контрагента"); wrd.Selection.MoveRight; wrd.Selection.Cells.Split(1,2); wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("Категория качества"); wrd.Selection.MoveRight; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("Размер резерва в %"); wrd.Selection.MoveRight; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("Элемент расчетной базы"); wrd.Selection.MoveRight; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("Сформированный резерв"); wrd.Selection.MoveRight; wrd.Selection.InsertRowsBelow(1); wrd.Selection.MoveLeft; wrd.Selection.MoveRight; wrd.Selection.MoveRight; wrd.Selection.MoveRight; wrd.Selection.Cells.Split(1,2); wrd.Selection.MoveRight; wrd.Selection.Cells.Split(1,2); wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.MoveLeft; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("1"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("2"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("3"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("4"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("5"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("6"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("7"); wrd.Selection.MoveRight; wrd.Selection.Font.Bold=0; wrd.Selection.ParagraphFormat.Alignment=1; wrd.Selection.Font.Size=8; wrd.Selection.TypeText("8"); wrd.Selection.MoveRight; wrd.Selection.InsertRowsBelow(1); /*Объединение ячеек*/ CurrentRow = 1; Cell = wrd.Selection.Tables(1).Cell(CurrentRow,1); Cell2 = wrd.Selection.Tables(1).Cell(CurrentRow + 1,1); Cell.Merge(Cell2); wrd.Visible = True; OnError(er) return false; exit(1);