Back to Devexpress

ISpreadsheetComponent.Unit Property

officefileapi-devexpress-dot-spreadsheet-dot-ispreadsheetcomponent-f0eb8356.md

latest6.8 KB
Original Source

ISpreadsheetComponent.Unit Property

Gets or sets a unit of measure used in the workbook.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
DocumentUnit Unit { get; set; }
vb
Property Unit As DocumentUnit

Property Value

TypeDescription
DocumentUnit

The DocumentUnit enumeration member. It is expected to be set to the DocumentUnit.Document value by default.

|

Available values:

NameDescription
Document

Specifies documents (one three-hundredths of an inch) as measurement units.

| | Inch |

Specifies inches as measurement units.

| | Millimeter |

Specifies millimeters as measurement units.

| | Centimeter |

Specifies centimeters as measurement units.

| | Point |

Specifies points as measurement units.

|

Remarks

By default, all workbooks loaded in the SpreadsheetControl gets the unit of measurement from the SpreadsheetControl.Unit property value. To specify the unit of measurement for the workbook explicitly, use the SpreadsheetControl.Document.Unit notation.

When the unit of measurement is changed, the ISpreadsheetComponent.UnitChanging and ISpreadsheetComponent.UnitChanged events occur.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Unit property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_API_Part02/SpreadsheetActions/PictureActions.cs#L31

csharp
// Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter;
try

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ShapeActions.cs#L25

csharp
// Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter;
try

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/ChartSheetActions.cs#L139

csharp
Worksheet worksheet = workbook.Worksheets["chartTask1"];
workbook.Unit = DevExpress.Office.DocumentUnit.Inch;

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/ChartSheetActions.cs#L139

csharp
Worksheet worksheet = workbook.Worksheets["chartTask1"];
workbook.Unit = DevExpress.Office.DocumentUnit.Inch;

winforms-spreadsheetcontrol-api-part1/CS/SpreadsheetControl/SpreadsheetActions/FormattingActions.cs#L417

csharp
range.ColumnWidthInCharacters = 30;
workbook.Unit = DevExpress.Office.DocumentUnit.Inch;
range.RowHeight = 1;

winforms-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_API_Part02/SpreadsheetActions/PictureActions.vb#L33

vb
' Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter
Try

wpf-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ShapeActions.vb#L27

vb
' Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter
Try

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/ChartSheetActions.vb#L134

vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")
workbook.Unit = DevExpress.Office.DocumentUnit.Inch

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/ChartSheetActions.vb#L133

vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")
workbook.Unit = DevExpress.Office.DocumentUnit.Inch

winforms-spreadsheetcontrol-api-part1/VB/SpreadsheetControl/SpreadsheetActions/FormattingActions.vb#L404

vb
range.ColumnWidthInCharacters = 30
workbook.Unit = DevExpress.Office.DocumentUnit.Inch
range.RowHeight = 1

See Also

ISpreadsheetComponent Interface

ISpreadsheetComponent Members

DevExpress.Spreadsheet Namespace