Create new files using Office for the web
Hosts can create new Office files using blank document templates from Office for the web. In order to support this, hosts use the editnew
WOPI action as follows:
- Create a zero-byte file with the appropriate file extension. Use
docx
for Word documents,pptx
for PowerPoint presentations, andxlsx
for Excel workbooks. - Run the
editnew
action on the newly created file. Office for the web detects that the file is zero bytes based on the Size property in the CheckFileInfo response.
Once the editnew
action runs, Office for the web runs a PutFile operation on the file, overwriting it with template content appropriate to the file type.
This PutFile operation is done on an unlocked file. Hosts must ensure that PutFile operations on the unlocked, zero bytes files succeed. For more information, see the PutFile documentation.
Important
Because creating new files is done in two steps, it's possible for the PutFile operation to fail, leaving the zero-byte file. Since such a file isn't valid, hosts should expect and handle this case. The ultimate solution is left to the host. Options for handling this situation include:
- Hide zero-byte files from the user.
- Prevent users from opening zero-byte files in Office for the web.
- If a file is zero bytes, when opening Office for the web against the file, always use the
editnew
action. (This is only an option if the user has edit permissions to the document.)
This isn't an exhaustive list of options; ultimately, the host must decide the best approach to this issue.