Как можно вставить изображение с помощью программы в ячейку таблицы? Тут приведен пример создания таблицы, а вот как засунуть изображение в ячейку не могу понять.
| Код | Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document wordDoc; Microsoft.Office.Interop.Word.Paragraph wordParag; Microsoft.Office.Interop.Word.Table wordTable;
//создаём новый документ Word и задаём параметры листа wordDoc = wordApp.Documents.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing); //создаём документ Word
// Word.Application application = new Word.Application(); Object missing = Type.Missing; //wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing); Clipboard.SetImage("C:\\123.png"); wordApp.ActiveDocument.Paragraphs[1].Range.Paste(); wordApp.Visible = true; // второй параграф, таблица из 10 строк и 2 колонок wordDoc.Paragraphs.Add(Type.Missing); wordParag.Range.Tables.Add(wordParag.Range, 10, 2, Type.Missing, Type.Missing); wordTable = wordDoc.Tables[1]; wordTable.Range.Font.Bold = 0; wordTable.Range.Font.Size = 12;
//задаём ширину колонок и высоту строк wordTable.Columns.PreferredWidthType = Microsoft.Office.Interop.Word.WdPreferredWidthType.wdPreferredWidthPoints; wordTable.Columns[1].SetWidth(200f, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone); wordTable.Rows.SetHeight(20f, Microsoft.Office.Interop.Word.WdRowHeightRule.wdRowHeightExactly); wordTable.Rows.Alignment = Microsoft.Office.Interop.Word.WdRowAlignment.wdAlignRowCenter; wordTable.Range.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; wordTable.Range.Select();
|
|