this.spreadsheet1.Workbook.Worksheets[0].DisplayOptions.MagnificationInNormalView = 150;
This topic explains how to programmatically set the zoom level on a worksheet.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
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.
The following table explains briefly the configurable aspects of the worksheet’s zooming.
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.
The following table maps the desired configuration to the property settings that manage it.
The following code snippet demonstrates how to set the zoom level to 150%.
In C#:
this.spreadsheet1.Workbook.Worksheets[0].DisplayOptions.MagnificationInNormalView = 150;
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%.
The following table maps the desired behavior to the command that manages it.
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>
You can set the zoom level to 100% using the ZoomTo100
command.
The following table maps the desired behavior to the command that manages it.
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>
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.
The following table maps the desired behavior to the command that manages it.
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>
The following topics provide additional information related to this topic.