word分页问题
void test()
{
//开启word对象
object Nothing = System.Type.Missing;
object format = System.Type.Missing;
Word.Application wordApp = new Word.ApplicationClass();
string rootPath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
if(rootPath.EndsWith("\\"))
{
rootPath = rootPath.Substring(0, rootPath.Length - 1);
}
string wordFileName = DateTime.Now.ToString("yyyyMMddhhmmssffff") + ".doc";
object srcFileName = rootPath + "\\temp\\" + wordFileName;
Word.Document wordDoc2 = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc2.Paragraphs.Last.Range.InsertFile(@"D:\Projects\SZPJXXB\temp\201105131120285312\jbszdy.html", ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//光标移动到文档最后一行。
wordApp.Selection.WholeStory();
object MoveUnit = Word.WdUnits.wdStory;
object MoveExtend = Type.Missing;
wordApp.Selection.EndKey(ref MoveUnit, ref MoveExtend);
//插入分页符
object BreakType = Word.WdBreakType.wdPageBreak;
wordApp.Selection.InsertBreak(ref BreakType);
wordDoc2.Paragraphs.Last.Range.InsertFile(@"D:\Projects\SZPJXXB\temp\201105130236554062\zbxxdy.html", ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordApp.Selection.EndKey(ref MoveUnit, ref MoveExtend);
wordApp.Selection.InsertBreak(ref BreakType);
wordDoc2.Paragraphs.Last.Range.InsertFile(@"D:\Projects\SZPJXXB\temp\201105131120285312\jbszdy.html", ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordApp.Selection.EndKey(ref MoveUnit, ref MoveExtend);
wordApp.Selection.InsertBreak(ref BreakType);
wordDoc2.Paragraphs.Last.Range.InsertFile(@"D:\Projects\SZPJXXB\temp\201105130236554062\zbxxdy.html", ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc2.SaveAs(ref srcFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc2.Close(ref Nothing, ref Nothing, ref Nothing);
if (wordDoc2 != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordDoc2);
wordDoc2 = null;
}
//关闭wordApp
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
if (wordApp != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp);
wordApp = null;
}
}
相关推荐
【PHPWord】解决Word转PDF可能出现的空白页问题 | 插入换行符、分页符、定义文档网络时对齐网格
换行符分页符定义文档网络时对齐网格。
前端开发组件示例源码_f1b6a91d详解
前端开发组件示例源码_f1b6a91d,内容包含源码/脚本与使用说明文档,结构清晰、注释完整,适合学习参考与二次开发,下载解压即可查看。
前端开发基于history.js的HTML5与HTML4浏览器兼容方案:单页应用无刷新历史状态管理技术实现-Gjl4Gf1792158475
内容概要:本文系统介绍了如何利用history.js实现单页应用(SPA)在HTML5c与HTML4浏览器间s草错发的无缝历史状态管理。通过封装原生History API并在不支持的浏览器中自动降级为哈希路由,history.js解决了因浏览器兼容性导致的后退按钮失效、URL混乱等问题。文章详细讲解了其核心机制,包括状态对象管理、自动模式切换(HTML5 pushState vs HTML4 哈希)、状态数据持久化以及针,对Safari、IE等浏\览器的兼容性修复方案,并提供了从入门到实战的完整示例,涵盖初始化、事,件监听、页面加载及性能优化技巧。;Gjl4Gf1792158475 www.gblp.net www.gsctlq.com gezhixq.cn www.greendalian.com wap.gxqnm.com
前端开发基于history.js的HTML5与HTML4浏览器兼容方案:单页应用无刷新历史状态管理技术实现-5Z6jeSqI1792158476
内容概要:本文系统介绍了如何利用history.js实现单页应用(SPA)在HTML5c与HTML4浏览器间s草错发的无缝历史状态管理。通过封装原生History API并在不支持的浏览器中自动降级为哈希路由,history.js解决了因浏览器兼容性导致的后退按钮失效、URL混乱等问题。文章详细讲解了其核心机制,包括状态对象管理、自动模式切换(HTML5 pushState vs HTML4 哈希)、状态数据持久化以及针,对Safari、IE等浏\览器的兼容性修复方案,并提供了从入门到实战的完整示例,涵盖初始化、事,件监听、页面加载及性能优化技巧。;5Z6jeSqI1792158476 sdhmgggw168.com www.shangliangwangye.com www.sdbing.net migu.blsxex.abxlbz.sc.cn www.safespeed.net.cn
高校如何通过科技报告服务提升技术转移转化效率?.docx
科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。


