Skip to main content

ASPxSpreadsheetBehaviorSettings.SaveAs Property

Specifies whether the Save As operation is permitted.

Namespace: DevExpress.Web.ASPxSpreadsheet

Assembly: DevExpress.Web.ASPxSpreadsheet.v24.1.dll

NuGet Package: DevExpress.Web.Office

Declaration

[DefaultValue(DocumentCapability.Default)]
public DocumentCapability SaveAs { get; set; }

Property Value

Type Default Description
DocumentCapability Default

The document’s capability to perform an operation. The Default value corresponds to the Enabled value.

Available values:

Name Description
Default

The value is determined by the current setting. The default value is automatically set if it is not explicitly specified.

Disabled

The feature is not allowed and the corresponding commands are shown disabled.

Enabled

The feature is available and the corresponding commands are shown enabled.

Hidden

The feature is not available and the corresponding commands are hidden.

Property Paths

You can access this nested property as listed below:

Object Type Path to SaveAs
ASPxSpreadsheetSettings
.Behavior .SaveAs

Remarks

The Spreadsheet displays the Save As dialog in the following cases:

  • A user clicks the Save As button.
  • A user clicks the “Save” button, but the document is new and the spreadsheet does not have any information about the path to save this document. The Save As dialog is shown to allow a user to specify the path.

If the SaveAs property is set to Disabled or Hidden, the Save As dialog is blocked and the save operation cannot be performed for a new file. Additionally, the Saving event does not fire because it requires a path to save the document.

In this case, you can use the following workaround: open a new document, save it to the server’s file system, and re-open the document.

protected void Page_Init(object sender, EventArgs e) {
    ASPxSpreadsheet1.Settings.Behavior.Save = DevExpress.XtraSpreadsheet.DocumentCapability.Enabled;
    ASPxSpreadsheet1.Settings.Behavior.SaveAs = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden;
}
protected void Page_Load(object sender, EventArgs e) {
    if(!Page.IsPostBack) {
        OpenNewDocument();
    }
}

private void OpenNewDocument() {
    var documentName = Guid.NewGuid().ToString();
    var path = Server.MapPath($"{ASPxSpreadsheet1.WorkDirectory}/{documentName}.xlsx");
    ASPxSpreadsheet1.New();
    ASPxSpreadsheet1.SaveCopy(path);
    ASPxSpreadsheet1.Open(path);
}
See Also