|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Create an object structure in ASP.NET Core Spreadsheet | Syncfusion |
| 4 | +description: Learn here all about how to create an object structure in ASP.NET Core Spreadsheet Control of Syncfusion Essential JS 2 and more. |
| 5 | +platform: document-processing |
| 6 | +control: Create a object structure |
| 7 | +documentation: ug |
| 8 | +--- |
| 9 | + |
| 10 | +# Create an object structure in ASP.NET Core Spreadsheet Control |
| 11 | + |
| 12 | +This topic guides you to construct a JSON structure that can be passed to the `openFromJson` method to render the spreadsheet. The JSON structure is an object with the key as `Workbook` and the [`properties`](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.spreadsheet.spreadsheet.html#properties) of the spreadsheet as value. |
| 13 | + |
| 14 | +```js |
| 15 | +{ Workbook: {} } |
| 16 | +``` |
| 17 | + |
| 18 | +The following properties are the root level properties of the `Workbook` object. |
| 19 | + |
| 20 | +| Property | Type | Description | |
| 21 | +|-------|-------|-------| |
| 22 | +| activeSheetIndex | number | Specifies active sheet index in the workbook. | |
| 23 | +| sheets | `Sheet[]` | Contains a list of sheet properties. | |
| 24 | +| definedNames | `DefineName[]` | Specifies the name for a range and uses it in the formula for calculation. | |
| 25 | + |
| 26 | +The following table defines each property of the `Sheet`. |
| 27 | + |
| 28 | +| Property | Type | Description | |
| 29 | +|-------|-------|-------| |
| 30 | +| name | string | Specifies the name of the sheet. | |
| 31 | +| selectedRange | string | Specifies selected range in the sheet. | |
| 32 | +| activeCell | string | Specifies active cell within `selectedRange` in the sheet. | |
| 33 | +| topLeftCell | string | Specified cell will be positioned at the upper-left corner of the sheet. | |
| 34 | +| showHeaders | boolean | Specifies to show or hide column and row headers in the sheet. | |
| 35 | +| showGridLines | boolean | Specifies to show or hide gridlines in the sheet. | |
| 36 | +| isProtected | boolean | Specifies to protect the cells in the sheet. | |
| 37 | +| state | [`SheetState`](../worksheet#sheet-visibility) | Specifies the sheet visibility state. There must be at least one visible sheet in Spreadsheet. | |
| 38 | +| columns | `Column[]` | Contains a list of column properties | |
| 39 | +| rows | `Row[]` | Contains a list of row properties | |
| 40 | +| protectSettings | [`ProtectSettings`](../protect-sheet#protect-sheet) | Configures protect and its options. | |
| 41 | +| conditionalFormats | `ConditionalFormat[]` | Specifies the conditional formatting for the sheet. | |
| 42 | + |
| 43 | +The following table defines each property of the `Column`. |
| 44 | + |
| 45 | +| Property | Type | Description | |
| 46 | +|-------|-------|-------| |
| 47 | +| width | number | Specifies the width of the column. | |
| 48 | +| customWidth | boolean | Specifies custom width of the column. | |
| 49 | +| hidden | boolean | To hide or show the column in the sheet. | |
| 50 | + |
| 51 | +The following table defines each property of the `Row`. |
| 52 | + |
| 53 | +| Property | Type | Description | |
| 54 | +|-------|-------|-------| |
| 55 | +| height | number | Specifies the height of the row. | |
| 56 | +| customHeight | boolean | Specifies the custom height of the row. | |
| 57 | +| hidden | boolean | To hide or show the row in the sheet. | |
| 58 | +| cells | `Cell[]` | Contains a list of cell properties | |
| 59 | + |
| 60 | +The following table defines each property of the `Cell`. |
| 61 | + |
| 62 | +| Property | Type | Description | |
| 63 | +|-------|-------|-------| |
| 64 | +| value | string | Defines the value of the cell which can be text or number. | |
| 65 | +| formula | string | Defines the formula or expression of the cell. | |
| 66 | +| format | string | Specifies the number format code to display the value in specified number format. | |
| 67 | +| hyperlink | string | Specifies the hyperlink of the cell. | |
| 68 | +| wrap | boolean | Wraps the cell text to the next line, if the text width exceeds the column width. | |
| 69 | +| isLocked | boolean | Specifies the cell whether it is locked or not, for allowing edit range in the spreadsheet protect option. | |
| 70 | +| colSpan | number | Specifies the column-wise cell merge count. | |
| 71 | +| rowSpan | number | Specifies the row-wise cell merge count. | |
| 72 | +| style | `CellStyle` | Specifies the cell style options. | |
| 73 | +| validation | `Validation` | Specifies the validation of the cell. | |
| 74 | +| image | `Image[]` | Specifies the image of the cell. | |
| 75 | + |
| 76 | +The following table defines each property of the `CellStyle`. |
| 77 | + |
| 78 | +| Property | Type | Description | |
| 79 | +|-------|-------|-------| |
| 80 | +| fontFamily | `FontFamily` | Specifies font family of the cell. | |
| 81 | +| verticalAlign | `VerticalAlign` | Specifies vertical align of the cell. | |
| 82 | +| textAlign | `TextAlign` | Specifies text align style of the cell. | |
| 83 | +| textIndent | string | Specifies text indent style of the cell. | |
| 84 | +| color | string | Specifies font color of the cell. | |
| 85 | +| backgroundColor | string | Specifies the background color of the cell. | |
| 86 | +| fontWeight | `FontWeight` | Specifies font weight of the cell. | |
| 87 | +| fontStyle | `FontStyle` | Specifies font style of the cell. | |
| 88 | +| fontSize | string | Specifies font size of the cell. | |
| 89 | +| textDecoration | `TextDecoration` | Specifies text decoration of the cell. | |
| 90 | +| border | string | Specifies border of the cell. | |
| 91 | +| borderTop | string | Specifies top border of the cell. | |
| 92 | +| borderBottom | string | Specifies bottom border of the cell. | |
| 93 | +| borderLeft | string | Specifies left border of the cell. | |
| 94 | +| borderRight | string | Specifies right border of the cell. | |
| 95 | + |
| 96 | +```js |
| 97 | +type FontFamily = 'Arial' | 'Arial Black' | 'Axettac Demo' | 'Batang' | 'Book Antiqua' | 'Calibri' | 'Courier' | 'Courier New' | 'Din Condensed' | 'Georgia' | 'Helvetica' | 'Helvetica New' | 'Roboto' | 'Tahoma' | 'Times New Roman' | 'Verdana'; |
| 98 | +type VerticalAlign = 'bottom' | 'middle' | 'top'; |
| 99 | +type TextAlign = 'left' | 'center' | 'right'; |
| 100 | +type FontWeight = 'bold' | 'normal'; |
| 101 | +type FontStyle = 'italic' | 'normal'; |
| 102 | +type TextDecoration = 'underline' | 'line-through' | 'underline line-through' | 'none'; |
| 103 | +``` |
| 104 | + |
| 105 | +The following table defines each property of the `Validation`. |
| 106 | + |
| 107 | +| Property | Type | Description | |
| 108 | +|-------|-------|-------| |
| 109 | +| type | `ValidationType` | Specifies Validation Type. | |
| 110 | +| operator | `ValidationOperator` | Specifies Validation Operator. | |
| 111 | +| value1 | string | Specifies Validation Minimum Value. | |
| 112 | +| value2 | string | Specifies Validation Maximum Value. | |
| 113 | +| ignoreBlank | boolean | Specifies IgnoreBlank option in Data Validation. | |
| 114 | +| inCellDropDown | boolean | Specifies InCellDropDown option in Data Validation. | |
| 115 | +| isHighlighted | boolean | Specifies to allow Highlight Invalid Data. | |
| 116 | +| | | | |
| 117 | + |
| 118 | +```js |
| 119 | +type ValidationType = 'WholeNumber' | 'Decimal' | 'Date' | 'TextLength' | 'List' | 'Time'; |
| 120 | +type ValidationOperator = 'Between' | 'NotBetween' | 'EqualTo' | 'NotEqualTo' | 'LessThan' | 'GreaterThan' | 'GreaterThanOrEqualTo' | 'LessThanOrEqualTo'; |
| 121 | +``` |
| 122 | + |
| 123 | +The following table defines each property of the `Image`. |
| 124 | + |
| 125 | +| Property | Type | Description | |
| 126 | +|-------|-------|-------| |
| 127 | +| src | string | Specifies the image source. | |
| 128 | +| id | string | Specifies image element id. | |
| 129 | +| height | number | Specifies the height of the image. | |
| 130 | +| width | number | Specifies the width of the image. | |
| 131 | +| top | number | Specifies the top position of the image. | |
| 132 | +| left | number | Specifies the left position of the image. | |
| 133 | + |
| 134 | +The following table defines each property of the `ConditionalFormat`. |
| 135 | + |
| 136 | +| Property | Type | Description | |
| 137 | +|-------|-------|-------| |
| 138 | +| type | `HighlightCell` or `TopBottom` or `DataBar` or `ColorScale` or `IconSet` | Specifies Conditional formatting Type. | |
| 139 | +| format | `Format` | Specifies format. | |
| 140 | +| cFColor | `CFColor` | Specifies Conditional formatting Highlight Color. | |
| 141 | +| value | string | Specifies Conditional formatting value. | |
| 142 | +| range | string | Specifies Conditional formatting range. | |
| 143 | + |
| 144 | +```js |
| 145 | +type HighlightCell = 'GreaterThan' | 'LessThan' | 'Between' | 'EqualTo' | 'ContainsText' | 'DateOccur' | 'Duplicate' | 'Unique'; |
| 146 | +type TopBottom = 'Top10Items' | 'Bottom10Items' | 'Top10Percentage' | 'Bottom10Percentage' | 'BelowAverage' | 'AboveAverage'; |
| 147 | +type DataBar = 'BlueDataBar' | 'GreenDataBar' | 'RedDataBar' | 'OrangeDataBar' | 'LightBlueDataBar' | 'PurpleDataBar'; |
| 148 | +type ColorScale = 'GYRColorScale' | 'RYGColorScale' | 'GWRColorScale' | 'RWGColorScale' | 'BWRColorScale' | 'RWBColorScale' | 'WRColorScale' | 'RWColorScale' | 'GWColorScale' | 'WGColorScale' | 'GYColorScale' | 'YGColorScale'; |
| 149 | +type IconSet = 'ThreeArrows' | 'ThreeArrowsGray' | 'FourArrowsGray' | 'FourArrows' | 'FiveArrowsGray' | 'FiveArrows' | 'ThreeTrafficLights1' | 'ThreeTrafficLights2' | 'ThreeSigns' | 'FourTrafficLights' | 'FourRedToBlack' | 'ThreeSymbols' | 'ThreeSymbols2' | 'ThreeFlags' | 'FourRating' | 'FiveQuarters' | 'FiveRating' | 'ThreeTriangles' | 'ThreeStars' | 'FiveBoxes'; |
| 150 | +type CFColor = 'RedFT' | 'YellowFT' | 'GreenFT' | 'RedF' | 'RedT'; |
| 151 | +``` |
| 152 | + |
| 153 | +The following table defines each property of the `Format`. |
| 154 | + |
| 155 | +| Property | Type | Description | |
| 156 | +|-------|-------|-------| |
| 157 | +| format | string | Specifies the number format code to display the value in specified number format. | |
| 158 | +| style | `CellStyle` | Specifies the cell style options. | |
| 159 | + |
| 160 | +The following table defines each property of the `DefinedName`. |
| 161 | + |
| 162 | +| Property | Type | Description | |
| 163 | +|-------|-------|-------| |
| 164 | +| name | string | Specifies a name for the defined name, which can be used in the formula. | |
| 165 | +| scope | string | Specifies scope for the defined name. | |
| 166 | +| comment | string | Specifies comment for the defined name. | |
| 167 | +| refersTo | string | Specifies reference for the defined name. | |
| 168 | + |
| 169 | +In the following demo, the JSON structure is passed to the `openFromJson` method to render the spreadsheet in the [`created`](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.spreadsheet.spreadsheet.html#Syncfusion_EJ2_Spreadsheet_Spreadsheet_Created) event. |
| 170 | + |
| 171 | +{% tabs %} |
| 172 | +{% highlight cshtml tabtitle="CSHTML" %} |
| 173 | +{% include code-snippet/spreadsheet/asp-net-core/json-structure-cs1/tagHelper %} |
| 174 | +{% endhighlight %} |
| 175 | +{% highlight c# tabtitle="OpenController.cs" %} |
| 176 | +{% include code-snippet/spreadsheet/asp-net-core/json-structure-cs1/OpenController.cs %} |
| 177 | +{% endhighlight %} |
| 178 | +{% endtabs %} |
0 commit comments