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

免费自己制作网站方法游戏怎么开科技

免费自己制作网站方法,游戏怎么开科技,做网站为什么图片上传不了,专业设计网站排行榜win32com库基于wps对Word文档的基础操作 文章目录 win32com库基于wps对Word文档的基础操作新建/打开文档段落操作(Paragraph)字体设置(Font)图表操作(Shape) 参考链接: WAS API手册 新建/打开文档 import win32com import win32com.client as win32 # 启动WPS进程 word_obj …

win32com库基于wps对Word文档的基础操作

文章目录

    • win32com库基于wps对Word文档的基础操作
      • 新建/打开文档
      • 段落操作(Paragraph)
      • 字体设置(Font)
      • 图表操作(Shape)

参考链接: WAS API手册

新建/打开文档

import win32com
import win32com.client as win32
# 启动WPS进程
word_obj = win32.gencache.EnsureDispatch('KWPS.Application')
word_obj .Visible = 1
# 打开文件
dst_file = "你的文档路径"
dst_doc = word_obj.Documents.Open(dst_file)
# 新建文档 返回一个空白文档对象
dst_doc = word_obj.Documents.Add(dst_file)

段落操作(Paragraph)

# Paragraphs 返回所选内容、范围或文档中所有的段落的集合
# 获取全部段落
dst_Paragraphs = dst_doc.Paragraphs
# 获取第1段
dst_Paragraph = dst_doc.Paragraphs(1)# 段落方法
dst_Paragraph.Delete() # 删除段落dst_Paragraph.Select() # 选中段落# 设置段落水平对齐方式为居中对齐 其余对齐方式参考官方文档中的枚举变量 WdParagraphAlignment
dst_Paragraph.Alignment = 1# 设置段落垂直对齐方式为中心对齐 其余对齐方式参考官方文档中的枚举变量 WdBaselineAlignment
dst_Paragraph.BaseLineAlignment = 1# 设置段落段前、段后间距
dst_Paragraph.LineUnitBefore= 1 # 段前 单位 行
dst_Paragraph.LineUnitAfter = 1 # 段后 单位 行
dst_Paragraph.SpaceBefore = 12 # 段前 单位 磅
dst_Paragraph.SpaceAfter = 12 # 段后 单位 磅# 设置段落大纲级别 # 若段落样式为标题样式,则无法修改
dst_Paragraph.OutlineLevel = 1# 段落左缩进和右缩进
dst_Paragraph.CharacterUnitLeftIndent = 0 # 左缩进 单位 字符
dst_Paragraph.CharacterUnitRightIndent = 0 # 右缩进 单位 字符
dst_Paragraph.LeftIndent = 0 # 左缩进 单位 磅
dst_Paragraph.RightIndent = 0 # 右缩进 单位 磅# 段落首行缩进、悬挂缩进 为正值时表示首行缩进,负值时表示悬挂缩进
dst_Paragraph.CharacterUnitFirstLineIndent = 2 #单位 字符
dst_Paragraph.FirstLineIndent = 12 #单位 磅# 设置段落行距为单倍行距 其余行距类型参考官方文档中的枚举变量 WdLineSpacing
dst_Paragraph.LineSpacingRule = 0# 若设置段落行距类型为固定值或多倍行距时 需要单独设置 LineSpacing属性
dst_Paragraph.LineSpacing = 12 # 其中一行等于12磅 或者使用 word_obj.LinesToPoints(1)进行计算
'''
WPS中各单位转换为磅值关系及方法如下:
1行 = 12磅 LinesToPoints()
1cm = 28.35磅 CentimetersToPoints()
1毫米 = 2.85磅 MillimetersToPoints()
1英寸 = 72磅 InchesToPoints()
像素 --> 磅 PixelsToPoints()
'''

字体设置(Font)

Paragraph = dst_doc.Paragraphs(1) # 获取第一段
'''
Range 表示对象在word文档中的连续区域
'''
# 设置段落字体中文样式
Paragraph.Range.Font.NameFarEast = "楷体_GB2312" # 设置中文字体
# 设置段落字体英文样式 其余样式详见开发文档
Paragraph.Range.Font.Name = "Times New Roman"
# 复杂文本
Paragraph.Range.Font.NameAscii = "Times New Roman"
# 设置字体大小
Paragraph.Range.Font.Size = 18 # 单位 磅 小二为18磅
# 设置字号
Paragraph.Range.Font.SizeFarEast = 3 #设置字体为3号# 字体加粗
Paragraph.Range.Font.Bold = True
# 字体倾斜
Paragraph.Range.Font.Italic = True
# 设置字符间距
Paragraph.Range.Font.Spacing = 1

图表操作(Shape)

# 获取第一个图表对象
dst_shape= dst_doc.Shapes(1)
# 设置大小
dst_shape.Height = 128 # 高
dst_shape.Width = 128 # 宽# 设置文字环绕
dst_shape.WrapFormat.Type = win32com.client.constants.wdWrapSquare  # 四周型 (wdWrapSquare)
dst_shape.WrapFormat.Side = win32com.client.constants.wdWrapBoth  # 环绕文字两边
# 设置四周边距
dst_shape.WrapFormat.DistanceTop = 0  # 上:0厘米
dst_shape.WrapFormat.DistanceBottom = 0  # 下:0厘米
dst_shape.WrapFormat.DistanceLeft = self.word.CentimetersToPoints(0.32)  # 左:0.32厘米
dst_shape.WrapFormat.DistanceRight = self.word.CentimetersToPoints(0.32)  # 右:0.32厘米
# 设置位置为页边距
dst_shape.RelativeHorizontalPosition = 0  # 1代表页边距
dst_shape.RelativeVerticalPosition = 0  # 1代表页边距
dst_shape.Top = 0
dst_shape.Left = 0
dst_shape.WrapFormat.AllowOverlap = False # 不允许重叠
嵌入式图表操作(InlineShape)
表格处理(Table、Row、Column、Cell)
dst_table = dst_doc.Tables(1)
# 获取行|列数
row_count = dst_table.Rows.Count
col_count = dst_table.Columns.Count
# 设置行高 单位 磅
dst_table.Rows(1).Height = 20
# 设置列宽
dst_table.Columns(1).Width = 20
# 设置表格的所有行的行高
dst_table.Rows.Height = 20# 设置单个单元格的宽高 PS设置时会自动修改其所在行和列的行高和列宽
dst_table.Cell(1,1).Height = 20
dst_table.Cell(1,1).Width = 20# 设置表格文本样式
dst_table.Cell(1,1).Range.Text = "设置文本"
# 设置字体样式(其余属性请参考Font设置)
dst_table.Cell(1,1).Font.Name = ""
# 调整单元格边距
dst_table.Rows(1).TopPadding = 20 # 上边距
dst_table.Rows(1).BottomPadding = 20 # 下边距
dst_table.Rows(1).LeftPadding = 20 # 左边距
dst_table.Rows(1).RightPadding = 20 # 右边距
http://www.yayakq.cn/news/25039/

相关文章:

  • 建设网站怎么收费wordpress 无法在线升级
  • 有关做有机肥的企业网站做数码后期上数码网站
  • 网站素材大全北京装修公司口碑最好的是哪家
  • 网站模板 黑白小程序制作实惠首选华网天下
  • 城阳做网站找哪家好网站的风格设计
  • 平台网站开发是什么意思wordpress前台加速
  • 网页图片批量下载seo网站推广的主要目的是什么
  • 怎样建设VR网站济宁推广
  • 网站建设开发软件哪些是+joomla做的网站
  • 免费网站搭建系统自己怎样做海外网站
  • 沈阳网站优化建设昵图网素材图库免费下载
  • 南坪做网站跨境电商需要投资多少
  • 西安做网站科技有限公司wordpress主题添加
  • 商业门户网站制作辽宁省网站制作
  • 东莞网站建设提供商自己做的网站图片打开慢
  • 会网站建设怎样赚钱西安百度公司电话
  • 怎么 网站 wordpress网站开发资金来源
  • 成都网站建设的费用百度2020新版下载
  • 广州网站制作哪里好搭建服务器需要多少钱
  • 中英文网站多少钱阿里巴巴 网站设计
  • 网站商城建设哪家好宣传类的网站有哪些内容
  • 外包网站开发安全吗竞价什么意思
  • 项目名称有创意大全seo1短视频网页入口营销
  • 网站虚拟服务器wordpress 相册形式
  • 网站的域名是什么意思国家能源局网站线路建设
  • 各类电子商务网站建设网站营销力
  • 网站制作与维护公司深圳网站设计哪好
  • 怎么让自己的电脑做网站服务器新的营销方式有哪些
  • 网站seo优化总结企业营销网站开发建设专家
  • 网站编程多少钱无锡网站制作推广公司