当前位置: 首页 > news >正文

美乐乐网站源码网站怎样做优惠卷

美乐乐网站源码,网站怎样做优惠卷,学校资源网站建设目标,安徽省省建设厅网站在Word文档中#xff0c;超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能。通过添加超链接#xff0c;用户可以轻松地导航到相关信息#xff0c;从而增强文档的互动性和可读性。本文将介绍如何使用Python在Word中添加超链接、或删除Word文档中的超…在Word文档中超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能。通过添加超链接用户可以轻松地导航到相关信息从而增强文档的互动性和可读性。本文将介绍如何使用Python在Word中添加超链接、或删除Word文档中的超链接。 文章目录 Python 在Word中添加超链接Python 删除Word中的超链接 要实现通过Python操作Word文档我们需要安装 Spire.Doc for Python 库。该库的pip安装命令如下 pip install Spire.Doc Python 在Word中添加超链接 Spire.Doc for Python 库提供了 AppendHyperlink() 方法来添加超链接其中三个参数 • link – 代表超链接地址 • text – 代表显示文本 也可传入picture来为图片添加超链接 • type – 代表超链接类型 包括网页链接WebLink、邮件链接EMailLink、书签链接Bookmark、文件链接FileLink 示例代码如下 from spire.doc import * from spire.doc.common import *# 创建Word文档 doc Document()# 添加一节 section doc.AddSection()# 添加一个段落 paragraph section.AddParagraph()# 添加一个简单网页链接 paragraph.AppendHyperlink(https://ABCD.com/, 主页, HyperlinkType.WebLink)# 添加换行符 paragraph.AppendBreak(BreakType.LineBreak) paragraph.AppendBreak(BreakType.LineBreak)# 添加一个邮箱链接 paragraph.AppendHyperlink(mailto:supporte-iceblue.com, 邮箱地址, HyperlinkType.EMailLink)# 添加换行符 paragraph.AppendBreak(BreakType.LineBreak) paragraph.AppendBreak(BreakType.LineBreak)# 添加一个文档链接 filePath C:\\Users\\Administrator\\Desktop\\排名.xlsx paragraph.AppendHyperlink(filePath, 点击查看文件, HyperlinkType.FileLink)# 添加换行符 paragraph.AppendBreak(BreakType.LineBreak) paragraph.AppendBreak(BreakType.LineBreak)# 添加一个新节并创建书签 section2 doc.AddSection() bookmarkParagrapg section2.AddParagraph() bookmarkParagrapg.AppendText(添加一个新段落) start bookmarkParagrapg.AppendBookmarkStart(书签) bookmarkParagrapg.Items.Insert(0, start) bookmarkParagrapg.AppendBookmarkEnd(书签)# 链接到书签 paragraph.AppendHyperlink(书签, 点击跳转到文档指定位置, HyperlinkType.Bookmark)# 添加换行符 paragraph.AppendBreak(BreakType.LineBreak) paragraph.AppendBreak(BreakType.LineBreak)# 添加一个图片超链接 image C:\\Users\\Administrator\\Desktop\\work1.jpg picture paragraph.AppendPicture(image) paragraph.AppendHyperlink(https://ABCD.com/, picture, HyperlinkType.WebLink)# 保存文档 doc.SaveToFile(Word超链接.docx, FileFormat.Docx2019); doc.Dispose()生成文档: Python 删除Word中的超链接 要删除 Word 文档中的所有超链接先用到了自定义方法 FindAllHyperlinks() 来查找文档中的所有超链接然后再通过自定义方法 FlattenHyperlinks() 来扁平化超链接。 示例代码如下 from spire.doc import * from spire.doc.common import *# 查找文档中的所有超链接 def FindAllHyperlinks(document):hyperlinks []for i in range(document.Sections.Count):section document.Sections.get_Item(i)for j in range(section.Body.ChildObjects.Count):sec section.Body.ChildObjects.get_Item(j)if sec.DocumentObjectType DocumentObjectType.Paragraph:for k in range((sec if isinstance(sec, Paragraph) else None).ChildObjects.Count):para (sec if isinstance(sec, Paragraph)else None).ChildObjects.get_Item(k)if para.DocumentObjectType DocumentObjectType.Field:field para if isinstance(para, Field) else Noneif field.Type FieldType.FieldHyperlink:hyperlinks.append(field)return hyperlinks# 扁平化超链接域 def FlattenHyperlinks(field):ownerParaIndex field.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.OwnerParagraph)fieldIndex field.OwnerParagraph.ChildObjects.IndexOf(field)sepOwnerPara field.Separator.OwnerParagraphsepOwnerParaIndex field.Separator.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.Separator.OwnerParagraph)sepIndex field.Separator.OwnerParagraph.ChildObjects.IndexOf(field.Separator)endIndex field.End.OwnerParagraph.ChildObjects.IndexOf(field.End)endOwnerParaIndex field.End.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.End.OwnerParagraph)FormatFieldResultText(field.Separator.OwnerParagraph.OwnerTextBody,sepOwnerParaIndex, endOwnerParaIndex, sepIndex, endIndex)field.End.OwnerParagraph.ChildObjects.RemoveAt(endIndex)for i in range(sepOwnerParaIndex, ownerParaIndex - 1, -1):if i sepOwnerParaIndex and i ownerParaIndex:for j in range(sepIndex, fieldIndex - 1, -1):field.OwnerParagraph.ChildObjects.RemoveAt(j)elif i ownerParaIndex:for j in range(field.OwnerParagraph.ChildObjects.Count - 1, fieldIndex - 1, -1):field.OwnerParagraph.ChildObjects.RemoveAt(j)elif i sepOwnerParaIndex:for j in range(sepIndex, -1, -1):sepOwnerPara.ChildObjects.RemoveAt(j)else:field.OwnerParagraph.OwnerTextBody.ChildObjects.RemoveAt(i)# 将域转换为文本范围并清除文本格式 def FormatFieldResultText(ownerBody, sepOwnerParaIndex, endOwnerParaIndex, sepIndex, endIndex):for i in range(sepOwnerParaIndex, endOwnerParaIndex 1):para ownerBody.ChildObjects[i] if isinstance(ownerBody.ChildObjects[i], Paragraph) else Noneif i sepOwnerParaIndex and i endOwnerParaIndex:for j in range(sepIndex 1, endIndex):if isinstance(para.ChildObjects[j], TextRange):FormatText(para.ChildObjects[j])elif i sepOwnerParaIndex:for j in range(sepIndex 1, para.ChildObjects.Count):if isinstance(para.ChildObjects[j], TextRange):FormatText(para.ChildObjects[j])elif i endOwnerParaIndex:for j in range(0, endIndex):if isinstance(para.ChildObjects[j], TextRange):FormatText(para.ChildObjects[j])else:for j, unusedItem in enumerate(para.ChildObjects):if isinstance(para.ChildObjects[j], TextRange):FormatText(para.ChildObjects[j])# 设置文本样式 def FormatText(tr):tr.CharacterFormat.TextColor Color.get_Black()tr.CharacterFormat.UnderlineStyle UnderlineStyle.none# 加载Word文档 doc Document() doc.LoadFromFile(Word超链接.docx)# 获取所有超链接 hyperlinks FindAllHyperlinks(doc)# 扁平化超链接 for i in range(len(hyperlinks) - 1, -1, -1):FlattenHyperlinks(hyperlinks[i])# 保存文件 doc.SaveToFile(删除超链接.docx, FileFormat.Docx) doc.Close()生成文件 如何去除水印点击申请一个月试用授权 https://www.e-iceblue.com/TemLicense.html
http://www.w-s-a.com/news/774728/

相关文章:

  • 商城网站建设报价方案导师让做网站
  • 清远市企业网站seo联系方式动易官方网站
  • 手机上怎么做能打开的网站一级域名和二级域名跨域
  • 网站首页效果图wordpress 在线教育
  • 电商网站开发团队广西桂林商贸旅游技工学校
  • 网站模板文件怎么下载东莞常平镇邮政编码
  • 建网站需要什么wordpress误删的后果
  • wordpress无插件实现网站地图做阿里巴巴网站店铺装修费用
  • 英文互动网站建设南宁住房和城乡建设局网站
  • 威海微网站建设乐清建网站哪家强
  • 网站和app的开发成本saas系统开发教程
  • ps切片工具做网站大气简洁网站
  • 网至普的营销型网站建设wordpress邮箱验证插件下载
  • 找权重高的网站方法张家港早晨网站建设
  • WordPress数据库添加管理员关键词优化举例
  • 河南国基建设集团--官方网站wordpress qode
  • 做农村电子商务的网站有哪些内容静态网站模板古典
  • 导航网站设计方案个人网站推广方法
  • 网站排名易下拉教程防wordpress花园
  • 计算机网站建设 是什么意思现在网站建站的主流语言是什么
  • php网站跟随导航西安百姓网免费发布信息网
  • 濮阳做公司网站html5 特效网站
  • ppt设计器怎么打开深圳seo网络推广营销
  • 建设银行网站用360浏览器建设信用卡中心网站
  • 创建公司网站 教程广州建设局
  • 详述网站建设的过程简答题ui培训设计怎么样
  • 动易网站官网ppt主题大全素材
  • 怎样用eclipse做网站可以做宣传图的网站
  • 哪里可以做游戏视频网站做网站平台应该注意哪些
  • 网站后期推广是谁来做网页制作步骤作答题