跳到主要内容

CreateFile(创建文件)

创建一个新文件。需要设置将要创建的文件类型。

语法

def CreateFile(self, int | str type);

参数

参数类型描述
typeint | str要创建的文件类型,在Python代码中设置为十六进制整数,在.docbuilder脚本文件中设置为docxxlsxpptxpdf(参见OFFICESTUDIO_FILE_XXX值)。

示例

import os
import docbuilder

builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")

dstPath = os.getcwd() + "/result.docx"
builder.SaveFile("docx", dstPath)
builder.CloseFile()