在书签位置插入文字
Document document = new Document ( Server. MapPath ( "~/File/评价结果.doc" ) ) ;
BookmarksNavigator bn = new BookmarksNavigator ( document) ;
Section newSec = document. AddSection ( ) ;
var name = "张三" ;
newSec. AddParagraph ( ) . AppendText ( name) ;
ParagraphBase firstReplacementParagraph = newSec. Paragraphs[ 0 ] . Items. FirstItem as ParagraphBase ;
ParagraphBase lastReplacementParagraph = newSec. Paragraphs[ newSec. Paragraphs. Count - 1 ] . Items. LastItem as ParagraphBase ;
TextBodySelection selection = new TextBodySelection ( firstReplacementParagraph, lastReplacementParagraph) ;
TextBodyPart part = new TextBodyPart ( selection) ;
bn. MoveToBookmark ( "name" , true , true ) ;
bn. DeleteBookmarkContent ( true ) ;
bn. ReplaceBookmarkContent ( part, true , true ) ;
在书签位置插入图片
Document document = new Document ( Server. MapPath ( "~/File/评价结果.doc" ) ) ;
BookmarksNavigator bn = new BookmarksNavigator ( document) ;
bn. MoveToBookmark ( "图片" , true , true ) ;
Section section0 = document. AddSection ( ) ;
Paragraph paragraph = section0. AddParagraph ( ) ;
Image image = Image. FromFile ( "1.png" ) ;
DocPicture picture = paragraph. AppendPicture ( image) ;
bn. InsertParagraph ( paragraph) ;
document. Sections. Remove ( section0) ;
在书签位置插入图表
Document document = new Document ( Server. MapPath ( "~/File/Model/地下水动态监测系统简报-周报.doc" ) ) ;
BookmarksNavigator bn = new BookmarksNavigator ( document) ;
var section0 = document. AddSection ( ) ;
var newPara = section0. AddParagraph ( ) ;
var shape = newPara. AppendChart ( ChartType. Column, 400 , 252 ) ;
Chart chart = shape. Chart;
chart. Title. Text = "柱状图" ;
ChartSeriesCollection seriesColl = chart. Series;
seriesColl. Clear ( ) ;
string [ ] categories1 = new string [ ] { "甲" , "乙" , "丙" , "丁" } ;
double [ ] dataArr1 = new double [ ] { 1.1 , 2.2 , 3.3 , 4.4 } ;
string [ ] categories2 = new string [ ] { "甲" , "乙" , "丙" , "丁" } ;
double [ ] dataArr2 = new double [ ] { 5.5 , 6.6 , 7.7 , 8.8 } ;
seriesColl. Add ( "李四" , categories1, dataArr1) ;
seriesColl. Add ( "张三" , categories2, dataArr2) ;
bn. MoveToBookmark ( "SWZZT" , true , true ) ;
bn. InsertParagraph ( newPara) ;
document. Sections. Remove ( section0) ;