Workbook.DefaultStyle

Workbook.DefaultStyle property

Gets or sets the default Style object of the workbook.

public Style DefaultStyle { get; set; }

Remarks

The DefaultStyle property is useful to implement a Style for the whole Workbook.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class WorkbookPropertyDefaultStyleDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            
            // Get the default style and modify its font
            Style defaultStyle = workbook.DefaultStyle;
            defaultStyle.Font.Name = "Tahoma";
            defaultStyle.Font.Size = 12;
            
            // Apply the modified style back as default
            workbook.DefaultStyle = defaultStyle;
            
            // Create a worksheet and add some text with default style
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("This text uses the default Tahoma font");
            
            // Save the workbook
            workbook.Save("DefaultStyleDemo.xlsx");
        }
    }
}

See Also