Version

Setting the Worksheet Zoom Level (Infragistics Excel Engine)

Topic Overview

Purpose

This topic explains how to programmatically set the zoom level on a worksheet.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

In this section you will find information that will help you to better understand the object model and the functionalities of the Infragistics Excel Engine.

Introduction

Zooming summary

The worksheet allows you to control the magnification (zooming) level. The xamSpreadsheet control tries to scale the view content’s presentation (text, images, shapes …) consistently, however the cell borders are not scaled.

Zoom Level Configuration Summary

Headers configuration summary chart

The following table explains briefly the configurable aspects of the worksheet’s zooming.

Configurable aspect Details Property/Command

Sets the worksheet’s zoom level at a specific value.

Increase or decrease zoom level by 10%.

  • ZoomIn

  • ZoomOut

Sets the zoom level at exactly 100%.

ZoomTo100

Sets the zoom level where all selection fits in the view.

ZoomToSelection

Setting the Zoom Level

Overview

You can change the zoom for each worksheet independently using the MagnificationInNormalView property on the DisplayOptions object. This property takes a value between 10 and 400.

Property settings

The following table maps the desired configuration to the property settings that manage it.

In order to: Use this property: And set it to:

Change zoom level

MagnificationInNormalView

To an int type value between 10 and 400.

Example

The following code snippet demonstrates how to set the zoom level to 150%.

In C#:

this.spreadsheet1.Workbook.Worksheets[0].DisplayOptions.MagnificationInNormalView = 150;

Increasing and Decreasing the Zoom Level

Overview

You can increase or decrease the worksheet’s zoom level using commands. The ZoomIn command increases the magnification level by 10% and the ZoomOut command decreases the magnification level by 10%.

Property settings

The following table maps the desired behavior to the command that manages it.

In order to: Use this command:

Increase zoom level

ZoomIn

Decrease zoom level

ZoomOut

Example

The following code snippet demonstrates how to create two buttons for increase and decrease zoom level.

In XAML:

<Button Content="Zoom In"
    ig:Commanding.CommandTarget="{Binding ElementName=xamSpreadsheet1}">
    <ig:Commanding.Command>
        <igPrim:SpreadsheetCommandSource
            EventName="Click" CommandType="ZoomIn" />
    </ig:Commanding.Command>
</Button>
<Button Content="Zoom Out"
    ig:Commanding.CommandTarget="{Binding ElementName=xamSpreadsheet1}">
    <ig:Commanding.Command>
        <igPrim:SpreadsheetCommandSource
            EventName="Click" CommandType="ZoomOut" />
    </ig:Commanding.Command>
</Button>

Setting the Zoom Level To 100%

Overview

You can set the zoom level to 100% using the ZoomTo100 command.

Property settings

The following table maps the desired behavior to the command that manages it.

In order to: Use this command:

Set zoom level to 100%

ZoomTo100

Example

The following code snippet demonstrates how to create a button for setting the zoom level to 100%.

In XAML:

<Button Content="Zoom To 100%"
    ig:Commanding.CommandTarget="{Binding ElementName=xamSpreadsheet1}">
    <ig:Commanding.Command>
        <igPrim:SpreadsheetCommandSource
            EventName="Click" CommandType="ZoomTo100" />
    </ig:Commanding.Command>
</Button>

Setting the Zoom Level to Selection

Overview

You can set the zoom level of the worksheet to a level where all selected cells are visible at once by using the ZoomToSelection command.

Property settings

The following table maps the desired behavior to the command that manages it.

In order to: Use this command:

Set zoom to selection level

ZoomToSelection

Example

The following code snippet demonstrates how to create a button for setting the zoom level to selection.

In XAML:

<Button Content="Zoom To Selection"
    ig:Commanding.CommandTarget="{Binding ElementName=xamSpreadsheet1}">
    <ig:Commanding.Command>
        <igPrim:SpreadsheetCommandSource
            EventName="Click" CommandType="ZoomToSelection" />
    </ig:Commanding.Command>
</Button>

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to show or hide the gridlines and set their color.

This topic explains how to show or hide the column and row headers.

This topic explains how to prevent the user from editing the cell values in a worksheet.