You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [openFromJson](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#openfromjson) method lets you load a complete workbook into the Spreadsheet using a JSON object. This JSON is usually created on the server after converting an Excel file, but it can also be generated manually. The method reads the JSON and restores all sheets, cells, styles, formulas, formatting, and other workbook details inside the component.
166
+
167
+
openFromJson is used because it provides a smooth and reliable way to load Excel data into the browser without needing the actual Excel file. Since the file is already processed into JSON on the server, the client only handles lightweight data. This reduces the workload on the browser and ensures that the document structure, formatting, and content appear exactly as intended. It also allows developers to modify or build workbook data directly in JSON form before loading it into the spreadsheet.
168
+
169
+
The main benefit for users is a faster and more stable loading experience. Because the heavy Excel‑processing work is completed on the server, the spreadsheet opens quickly in the browser and maintains the correct layout, values, and styles. The JSON format helps avoid common issues that might occur with large or complex Excel files, making the entire experience more dependable and easier for users.
170
+
171
+
The following code snippet demonstrates openFromJson method:
172
+
173
+
{% tabs %}
174
+
{% highlight js tabtitle="app.jsx" %}
175
+
{% include code-snippet/spreadsheet/react/open-from-json-cs1/app/app.jsx %}
176
+
{% endhighlight %}
177
+
{% highlight ts tabtitle="app.tsx" %}
178
+
{% include code-snippet/spreadsheet/react/open-from-json-cs1/app/app.tsx %}
By default, the Spreadsheet component provides an option to browse files from the local file system and open them within the component. If you want to load an Excel file located on a server, you need to configure the server endpoint to fetch the Excel file from the server location, process it using `Syncfusion.EJ2.Spreadsheet.AspNet.Core`, and send it back to the client side as `JSON data`. On the client side, you should use the [openFromJson](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#openfromjson) method to load that `JSON data` into the Spreadsheet component.
Copy file name to clipboardExpand all lines: Document-Processing/Excel/Spreadsheet/React/rows-and-columns.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,12 @@ You can change the size of rows and columns in the spreadsheet by using [setRows
155
155
156
156
You can change the height of single or multiple rows by using the [setRowsHeight](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#setrowsheight) method.
157
157
158
+
There is a property `customHeight` on a row’s model that indicates the row height has been explicitly set by dragging the row header boundary with the mouse or by a programmatic resize. The Spreadsheet sets this property using the setRow method during a resize operation.
159
+
160
+
When customHeight is true, it means the height was manually defined rather than automatically determined from cell content or formatting.
161
+
162
+
Actions such as enabling Wrap Text, increasing font size, or changing the font family do not set `customHeight` property.
163
+
158
164
You can provide the following type of ranges to the method:
159
165
160
166
* Single row range: `['2:2']`
@@ -185,6 +191,12 @@ The following code example shows how to change the height for single/multiple ro
185
191
186
192
You can change the width of single or multiple columns by using the [setColumnsWidth](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#setcolumnswidth) method.
187
193
194
+
There is a property `customWidth` on a column’s model that indicates the column width has been explicitly set by dragging the column header boundary with the mouse or by a programmatic resize. The Spreadsheet sets this property using the `setColumn` method during a resize operation.
195
+
196
+
When `customWidth` is true, it means the width was manually defined rather than automatically determined based on cell content or formatting.
197
+
198
+
Actions such as enabling Wrap Text, increasing font size, or changing the font family do not set `customHeight` property.
199
+
188
200
You can provide the following type of ranges to the method:
serializes the current workbook into a JSON object that contains sheets, cell data, styles, formulas, and workbook settings. you can store that object and later restore it with openFromJson.
140
+
141
+
The [saveAsJson](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#saveasjson) method converts the entire Spreadsheet workbook into a JSON object. This JSON includes sheets, cell values, formulas, styles, formatting, charts, and other workbook settings. It acts as a complete representation of the current spreadsheet state, which can be stored, sent to a server, or later restored using openFromJson.
142
+
143
+
saveAsJson is used to capture the full state of the Spreadsheet in a simple, structured format. Instead of creating an Excel file immediately, the workbook is converted into JSON, which is easier for applications to handle. This makes it useful when you want to store spreadsheet data temporarily, save it to a database, send it through an API, or allow another system to process or modify the data before creating an Excel file. It also helps when you want to restore the same workbook later without losing styles, formulas, or layout.
144
+
145
+
The main benefit for users is that the Spreadsheet state can be saved quickly without waiting for the server to generate an Excel file. Because JSON is lightweight, it can be stored or transferred very fast, making the save operation feel smoother. When the JSON is loaded again, the workbook looks exactly as before, which gives users a consistent experience. This also reduces errors and makes the application more responsive during save operations.
146
+
147
+
148
+
The following code snippet demonstrates saveAsJson method:
149
+
150
+
{% tabs %}
151
+
{% highlight js tabtitle="app.jsx" %}
152
+
{% include code-snippet/spreadsheet/react/save-as-json-cs1/app/app.jsx %}
153
+
{% endhighlight %}
154
+
{% highlight ts tabtitle="app.tsx" %}
155
+
{% include code-snippet/spreadsheet/react/save-as-json-cs1/app/app.tsx %}
By default, the Spreadsheet control saves the Excel file and downloads it to the local file system. If you want to save an Excel file to a server location, you need to configure the server endpoint to convert the spreadsheet data into a file stream and save it to the server location. To do this, first, on the client side, you must convert the spreadsheet data into `JSON` format using the [saveAsJson](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#saveasjson) method and send it to the server endpoint. On the server endpoint, you should convert the received spreadsheet `JSON` data into a file stream using `Syncfusion.EJ2.Spreadsheet.AspNet.Core`, then convert the stream into an Excel file, and finally save it to the server location.
0 commit comments