python-docx WD_LINE_SPACING.SINGLE不起作用

时间:2018-07-04 02:47:52

标签: python python-docx

非常简单的代码:

ALTER FUNCTION [dbo].[UDF_GetNumeric]
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END

当我在MS Word中打开 demo.docx 时,我看到行距是多个。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找的是.line_spacing_rule对象上的ParagraphFormat属性:

from docx.enum.text import WD_LINE_SPACING
from docx import Document

document = Document()
paragraph = document.add_paragraph('test line spacing')
paragraph.paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE
document.save('demo.docx')