Zooming In or Out On the Worksheet in GridDesktop

Zooming In or Out Using Aspose.Cells.GridDesktop

Aspose.Cells provides Aspose.Cells.GridDesktop.Worksheet class that has a wide range of properties and methods for managing worksheets. To set a worksheet’s zoom factor, use the Worksheet class' Zoom property. The zoom factor is set by assigned a numeric (integer) value to the Zoom property.

We build an MS Excel like zoom slider using TrackBar (.NET) control. In a WinForm project, we place the Aspose.Cells.GridDesktop control from Toolbox to the form and specify some properties to set its name, size or other aspects accordingly. Now, we place the TrackBar control @ lower right corner below the GridDesktop control, we also put a Label control that would show the percentage value you specify via TrackBar control’s handle. We add relative lines of code in TrackBar’s Scroll event, so when you scroll the Trackbar control, GridDesktop should zoom in or out to show the data/ contents in it.

A complete example is given below that demonstrates how to use the Zoom property to set the zoom factor of the active worksheet of GridDesktop. We first import a template Excel file to GridDesktop.

Write below code in the Load event of form to set the template Excel file in GridDesktop and trackbar value.

Now copy below code inside track scroll event and run the application. You will notice that moving track bar will change the zoom property of worksheet.