8,834
社区成员
发帖
与我相关
我的任务
分享
string tmppath = Server.MapPath("~/Template.doc");
Document doc = new Document(tmppath); //载入模板
//使用书签
if (doc.Range.Bookmarks["mark"] != null)
{
// Bookmark mark = doc.Range.Bookmarks["mark"];//根据书签名称获取书签
//mark.Text = "sean";
}
//不使用书签 通过移动单元格 来添加值
DocumentBuilder builder = new DocumentBuilder(doc);
//设置单元格内容对齐方式
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.MoveToCell(0, 2, 3,0); //表格索引,rowIndex,columnIndex,characterIndex
builder.Write("chang");
doc.Save("demo.doc", SaveFormat.Doc, SaveType.OpenInWord, Response); //保存为doc,并打开
//doc.Save(HttpContext.Current.Server.MapPath(savePath), SaveFormat.Doc);//直接保存文件