日期:2014-05-16 浏览次数:20480 次
public string CreateWordFile(string CheckedInfo)
{
string message = "";
try
{
Object Nothing = System.Reflection.Missing.Value;
Directory.CreateDirectory("C:\\CNSI"); //创建文件所在目录
string name = "CNSI.doc";
object filename = "C:\\CNSI\\" + name; //文件保存路径
//创建Word文档
Word.Application WordApp = new Word.ApplicationClass();
Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("[页眉内容]");
WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;//设置右对齐
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;//跳出页眉设置
WordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距
/*WordDoc.PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape; //设置页面为纵向
WordDoc.PageSetup.PageHeight = WordApp.CentimetersToPoints(21F);
WordDoc.PageSetup.PageWidth =