CreateFile
Creates a new file. The type of the file which will be created needs to be set.
Syntax
- Python
- C++
- COM
- Java
- .Net
- JS
def CreateFile(self, type: int | str) -> bool
bool CreateFile(int nExtension);
HRESULT CreateFile([in] BSTR type, [out, retval] VARIANT_BOOL* result);
boolean createFile(int | String type);
bool CreateFile(int nType);
CreateFile(type)
Parameters
- Python
- C++
- COM
- Java
- .Net
- JS
| Name | Type | Description |
|---|---|---|
| type | int | str | The file type as a hexadecimal integer (OFFICESTUDIO_FILE_XXX values) or a string (docx, xlsx, pptx, pdf). |
| Name | Type | Description |
|---|---|---|
| nExtension | int | The type of the file to be created set as a hexadecimal integer (see OFFICESTUDIO_FILE_XXX values). |
| Name | Type | Description |
|---|---|---|
| type | BSTR | The file extension (see Supported formats). |
| result | VARIANT_BOOL* | Specifies if the operation of creating a file is successful or not. |
| Name | Type | Description |
|---|---|---|
| type | int | String | The file type as a hexadecimal integer (OFFICESTUDIO_FILE_XXX values) or a string (docx, xlsx, pptx, pdf). |
| Name | Type | Description |
|---|---|---|
| nType | int | The type of the file to be created set as a hexadecimal integer (see OFFICESTUDIO_FILE_XXX values). |
| Name | Type | Description |
|---|---|---|
| type | String | The file extension (see Supported formats). |
Example
- Python
- C++
- COM
- Java
- .Net
- JS
import os
import docbuilder
builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")
dstPath = os.getcwd() + "/result.docx"
builder.SaveFile("docx", dstPath)
builder.CloseFile()
std::wstring sWorkDirectory = NSUtils::GetBuilderDirectory();
CDocBuilder::Initialize(sWorkDirectory.c_str());
CDocBuilder oBuilder;
oBuilder.CreateFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX);
CDocBuilder::Dispose();
CoInitialize(NULL);
IONLYOFFICEDocBuilder* oBuilder = NULL;
VARIANT_BOOL b;
oBuilder->Initialize();
oBuilder->CreateFile(_bstr_t("docx"), &b);
oBuilder->Dispose();
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.createFile(FileTypes.Document.DOCX);
CDocBuilder.dispose();
string workDirectory = "C:/Program Files/ONLYOFFICE/documentBuilder";
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
var doctype = (int)OfficeFileTypes.Document.DOCX;
oBuilder.CreateFile(doctype);
CDocBuilder.Destroy();
builder.CreateFile("docx");
builder.SaveFile("docx", "result.docx");
builder.CloseFile();