Back to Devexpress

CsvExportOptions.EncodeExecutableContent Property

corelibraries-devexpress-dot-xtraprinting-dot-csvexportoptions.md

latest3.8 KB
Original Source

CsvExportOptions.EncodeExecutableContent Property

Gets or sets whether to encode potentially dangerous content from a control or document when it is exported to a CSV file.

Namespace : DevExpress.XtraPrinting

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
[Browsable(false)]
[DefaultValue(DefaultBoolean.Default)]
public DefaultBoolean EncodeExecutableContent { get; set; }
vb
<DefaultValue(DefaultBoolean.Default)>
<Browsable(False)>
Public Property EncodeExecutableContent As DefaultBoolean

Property Value

TypeDefaultDescription
DefaultBooleanDefault

True , to encode potentially dangerous content; otherwise, False. Default , to use the ExportSettings.EncodeCsvExecutableContent property value.

|

Available values:

NameDescriptionReturn Value
True

The value is true.

|

0

| | False |

The value is false.

|

1

| | Default |

The value is specified by a global option or a higher-level object.

|

2

|

Property Paths

You can access this nested property as listed below:

Object TypePath to EncodeExecutableContent
ExportOptions

.Csv .EncodeExecutableContent

|

Remarks

Exported data can contain executable content. Such content makes it possible to execute dangerous commands if a user opens a file in Microsoft Excel and confirms that the file can be loaded and commands executed.

Set the EncodeExecutableContent property to True to add the quote character to a control or document’s executable content when it is exported to CSV.

If this property is set to Default , EncodeCsvExecutableContent property value is used.

csharp
// ASP.NET Web Forms GridView
protected void ExportToCSVButton_Click(object sender, EventArgs e){
    var options = new CsvExportOptionsEx();
    options.EncodeExecutableContent = DefaultBoolean.True;
    Grid.ExportCsvToResponse(options);
}

To encode executable content at the application level, use the ExportSettings.EncodeCsvExecutableContent property instead.

csharp
// ASP.NET
void Application_Start(object sender, EventArgs e) {
    DevExpress.Export.ExportSettings.EncodeCsvExecutableContent = DevExpress.Utils.DefaultBoolean.True;
}

Tip

The EncodeExecutableContent property overrides the EncodeCsvExecutableContent property. If EncodeExecutableContent is set to True , executable content is encoded even if EncodeCsvExecutableContent is set to False.

Note that EncodeExecutableContent is a security parameter whose value can only be set in code before the export operation is performed. The EncodeExecutableContent value is not stored with the saved report.

See Also

CsvExportOptions Class

CsvExportOptions Members

DevExpress.XtraPrinting Namespace