TSOffice/funcext/TSOffice/template/faq.txt

53 lines
3.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

*如何读取属性值?
对象的Value()函数可以获取属性值,例如:
★读取段落对象文字大小:
size := paragraph.Font.Value('Size');
★读取段落对象StyleID段落格式ID
styleId := paragraph.Format.Value('StyleId');
★读取段落对象numId数字编号ID
numId := paragraph.Format.NumPr.Value('numId');
*如何修改属性值?
Apply()函数可以修改属性值,例如:
★修改段落对象文字大小:
paragraph.Font.Size := 32;
paragraph.Apply();
*如何设置段落的项目编号?
★推荐先获取文档中已有的项目符号numId再设置新段落的项目编号
numId := oldParagraph.Format.NumPr.Value('numId'); //获取已有段落项目编号ID
newParagraph.Format.NumPr.ID := numID; //设置新段落numID
newParagraph.Format.NumPr.Level := numID; //设置项目编号级别
newParagraph.Apply();
★docx.Numberings()可以获取文档中已有的TNumberId对象列表但编程的角度理解项目编码样式比较麻烦。
★docx.NumberingObject()TNumbering对象可以用户自己插入项目编码innerXml串或自定义TNumberId对象
★系统默认提供的样式:
numId := docx.NumberingObject().NumberId('SingleLevel', 'decimal'); //数字型一级样式[如1、]
numId := docx.NumberingObject().NumberId('SingleLevel', 'chinese'); //中文型一级样式[如:一、]
numId := docx.NumberingObject().NumberId('multilevel', 'decimal'); //数字型多级样式[如1.1.1]
numId := docx.NumberingObject().NumberId('bullet', index); //项目编号index取值0-6
*如何设置段落的样式?
★推荐先获取文档中已有的段落样式;再设置新段落的样式:
styleId := oldParagraph.Format.Value('StyleId'); //获取已有段落StyleId
newParagraph.Format.StyleId := StyleId; //设置新段落StyleId
newParagraph.Apply();
★docx.StyleObject()TDocxStyles对象可以用户自己插入段落样式innerXml串或自定义TDocxStyle对象
*如何设置字符集(中文支持)?
★用户的脚本可能是UFT8格式或可能是GBK码格式系统提供API自动设置当前字符集环境
TOfficeApi().CodePage('中文'); //系统检测当前的环境字符集
...
p.Run.SetText('系统可以自动识别这里的中文字符集utf8或gbk');
★不设置默认当前字符集为UTF8
*报告模板功能TDocxFile::ExecInnerTSLWord中执行[TSL]...[/TSL]时的字符集是啥?
是GBK。
*TDocxFile::NewFile()创建的缺省word文档格式说明
1.5倍行距、默认5号字体、宋体。
*缺省文档格式不是我想要的,怎么办?
★用户可以利用word或wps生成自己想要格式的空文档调用TDocxFile::OpenFile()打开即可。
★用户甚至可以设计好文档封面、目录、页脚、页眉再调用TDocxFile::OpenFile()打开。
★用户可以在word文档中内嵌TSL代码调用TDocxFile::ExecInnerTSL()操作word文档。