Class TxtSaveOptions

TxtSaveOptions class

Represents the save options for csv/tab delimited/other text format.

public class TxtSaveOptions : SaveOptions

Constructors

NameDescription
TxtSaveOptions()Creates text file save options.
TxtSaveOptions(SaveFormat)Creates text file save options.

Properties

NameDescription
AlwaysQuoted { get; set; }(Obsolete.) Indicates whether always adding ‘"’ for each field. If true then all values will be quoted; If false then values will only be quoted when needed(for example, when values contain special characters such as ‘"’ , ‘\n’ or separator character). Default is false.
CachedFileFolder { get; set; }The cached file folder is used to store some large data.(Inherited from SaveOptions.)
ClearData { get; set; }Make the workbook empty after saving the file.(Inherited from SaveOptions.)
CreateDirectory { get; set; }If true and the directory does not exist, the directory will be automatically created before saving the file.(Inherited from SaveOptions.)
Encoding { get; set; }Gets and sets the default encoding.
EncryptDocumentProperties { get; set; }Indicates whether encrypt document properties when saving as .xls file. The default value is true.(Inherited from SaveOptions.)
ExportAllSheets { get; set; }Indicates whether exporting all sheets to the text file. If it is false, only export the activesheet, just like MS Excel.
ExportArea { get; set; }The range of cells to be exported.
ExportQuotePrefix { get; set; }Indicates whether the single quote sign should be exported as part of the value of one cell when QuotePrefix is true for it. Default is false.
FormatStrategy { get; set; }Gets and sets the format strategy when exporting the cell value as string.
KeepSeparatorsForBlankRow { get; set; }Indicates whether separators should be output for blank row. Default value is false so by default the content for blank row will be empty.
LightCellsDataProvider { get; set; }The data provider for saving workbook in light mode.
MergeAreas { get; set; }Indicates whether merge the areas of conditional formatting and validation before saving the file.(Inherited from SaveOptions.)
QuoteType { get; set; }Gets or sets how to quote values in the exported text file.
RefreshChartCache { get; set; }Indicates whether refreshing chart cache data(Inherited from SaveOptions.)
SaveFormat { get; }Gets the save file format.(Inherited from SaveOptions.)
Separator { get; set; }Gets and sets char Delimiter of text file.
SeparatorString { get; set; }Gets and sets a string value as separator.
SortExternalNames { get; set; }Indicates whether sorting external defined names before saving file.(Inherited from SaveOptions.)
SortNames { get; set; }Indicates whether sorting defined names before saving file.(Inherited from SaveOptions.)
TrimLeadingBlankRowAndColumn { get; set; }Indicates whether leading blank rows and columns should be trimmed like what ms excel does. Default is true.
TrimTailingBlankCells { get; set; }Indicates whether tailing blank cells in one row should be trimmed. Default is false.
UpdateSmartArt { get; set; }Indicates whether updating smart art setting. The default value is false.(Inherited from SaveOptions.)
ValidateMergedAreas { get; set; }Indicates whether validate merged cells before saving the file.(Inherited from SaveOptions.)
WarningCallback { get; set; }Gets or sets warning callback.(Inherited from SaveOptions.)

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;
    using System.Text;

    public class TxtSaveOptionsDemo
    {
        public static void TxtSaveOptionsExample()
        {
            // Create a workbook with some data
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("Name");
            worksheet.Cells["B1"].PutValue("Age");
            worksheet.Cells["A2"].PutValue("John Doe");
            worksheet.Cells["B2"].PutValue(30);
            worksheet.Cells["A3"].PutValue("Jane Smith");
            worksheet.Cells["B3"].PutValue(25);

            // Create TxtSaveOptions object and set properties
            TxtSaveOptions saveOptions = new TxtSaveOptions
            {
                Separator = ',',
                SeparatorString = ",",
                Encoding = Encoding.UTF8,
                AlwaysQuoted = false,
                QuoteType = TxtValueQuoteType.Normal,
                FormatStrategy = CellValueFormatStrategy.DisplayStyle,
                TrimLeadingBlankRowAndColumn = true,
                TrimTailingBlankCells = false,
                KeepSeparatorsForBlankRow = false,
                ExportArea = new CellArea { StartRow = 0, EndRow = 2, StartColumn = 0, EndColumn = 1 },
                ExportQuotePrefix = false,
                ExportAllSheets = false,
                ClearData = false,
                CachedFileFolder = "cache",
                ValidateMergedAreas = true,
                MergeAreas = true,
                SortNames = true,
                SortExternalNames = true,
                RefreshChartCache = true,
                UpdateSmartArt = false
            };

            // Save the workbook as a text file with the specified options
            workbook.Save("TxtSaveOptionsExample.txt", saveOptions);

            Console.WriteLine("Workbook saved successfully with TxtSaveOptions.");
        }
    }
}

See Also