Class DeleteBlankOptions

DeleteBlankOptions class

Represents the setting of deleting blank cells/rows/columns.

public class DeleteBlankOptions : DeleteOptions

Constructors

NameDescription
DeleteBlankOptions()The default constructor.

Properties

NameDescription
DrawingsAsBlank { get; set; }Whether drawing related objects such as picture, shape, chart… will be taken as blank. Default value is true.
EmptyFormulaValueAsBlank { get; set; }Whether one cell will be taken as blank when it is formula and the calculated result is null or empty string. Default value is false.
EmptyStringAsBlank { get; set; }Whether one cell will be taken as blank when its value is empty string. Default value is true.
EndIndex { get; set; }Specifies the end row/column index(inclusive) of the range to check and delete blank rows/columns. Default value is -1 and -1 means the maximum range of all objects(cells, drawings, …) that need to be checked.
MergedCellsShrinkType { get; set; }Indicates how to process merged cells when deleting blank rows/columns.
StartIndex { get; set; }Specifies the start row/column index of the range to check and delete blank rows/columns.
UpdateReference { get; set; }Indicates if update references in other worksheets.(Inherited from DeleteOptions.)

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class DeleteBlankOptionsDemo
    {
        public static void DeleteBlankOptionsExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Populate the worksheet with some data
            worksheet.Cells["A1"].PutValue("Data");
            worksheet.Cells["A2"].PutValue("");
            worksheet.Cells["A3"].PutValue("More Data");
            worksheet.Cells["A4"].PutValue("");
            worksheet.Cells["A5"].PutValue("Even More Data");

            // Create an instance of DeleteBlankOptions
            DeleteBlankOptions options = new DeleteBlankOptions
            {
                EmptyStringAsBlank = true,
                EmptyFormulaValueAsBlank = false,
                UpdateReference = true
            };

            // Delete blank rows based on the options
            worksheet.Cells.DeleteBlankRows(options);

            // Save the workbook
            workbook.Save("DeleteBlankOptionsExample.xlsx");
            workbook.Save("DeleteBlankOptionsExample.pdf");
            return;
        }
    }
}

See Also