aspnet-devexpress-dot-web-dot-aspxspreadsheet-dot-aspxspreadsheetbehaviorsettings-d267d989.md
Specifies whether the Save As operation is permitted.
Namespace : DevExpress.Web.ASPxSpreadsheet
Assembly : DevExpress.Web.ASPxSpreadsheet.v25.2.dll
NuGet Package : DevExpress.Web.Office
[DefaultValue(DocumentCapability.Default)]
public DocumentCapability SaveAs { get; set; }
<DefaultValue(DocumentCapability.Default)>
Public Property SaveAs As DocumentCapability
| 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.
|
You can access this nested property as listed below:
| Object Type | Path to SaveAs |
|---|---|
| ASPxSpreadsheetSettings |
.Behavior .SaveAs
|
The Spreadsheet displays the Save As dialog in the following cases:
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);
}
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
ASPxSpreadsheet1.Settings.Behavior.Save = DevExpress.XtraSpreadsheet.DocumentCapability.Enabled
ASPxSpreadsheet1.Settings.Behavior.SaveAs = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
OpenNewDocument()
End If
End Sub
Private Sub OpenNewDocument()
Dim documentName = Guid.NewGuid().ToString()
Dim path = Server.MapPath($"{ASPxSpreadsheet1.WorkDirectory}/{documentName}.xlsx")
ASPxSpreadsheet1.New
ASPxSpreadsheet1.SaveCopy(path)
ASPxSpreadsheet1.Open(path)
End Sub
See Also
ASPxSpreadsheetBehaviorSettings Class