跳到主要内容

CreateFile

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

语法

def CreateFile(self, type: int | str) -> bool

参数

名称类型描述
typeint | str文件类型,可以是十六进制整数(OFFICESTUDIO_FILE_XXX 值)或字符串(docxxlsxpptxpdf)。

示例

import os
import docbuilder

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

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