Skip to content

Commit d1d17b1

Browse files
Merge pull request #3092 from Syncfusion-Content/hotfix/hotfix-v26.1.35
DOCINFRA-2341_merged_using_automation
2 parents 8bb186a + 55922bf commit d1d17b1

File tree

7 files changed

+206
-1
lines changed

7 files changed

+206
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@Html.EJS().Button("fullRow").Content("Make row 2 Read Only").Render();
2+
@Html.EJS().Button("fullCol").Content("Make Column A Read Only").Render();
3+
@Html.EJS().Button("singleCell").Content("Make E5 cell Read Only").Render();
4+
@Html.EJS().Button("removeAll").Content("Remove Read Only").Render();
5+
@Html.EJS().Spreadsheet("spreadsheet").Sheets(sheet => {
6+
sheet.Name("Price Details").Ranges(ranges => {
7+
ranges.DataSource((IEnumerable<object>)ViewBag.DefaultData).StartCell("A1").Add();
8+
}).Rows(row =>
9+
{
10+
row.Index(3).IsReadOnly(true).Add();
11+
row.Index(4).Cells(cell =>
12+
{
13+
cell.Index(5).IsReadOnly(true).Add();
14+
}).Add();
15+
}).Columns(column => {
16+
column.Width(130).Add();
17+
column.Width(100).Add();
18+
column.Width(100).IsReadOnly(true).Add();
19+
}).Add();
20+
}).Render()
21+
22+
<script>
23+
24+
// To make row 2 readonly.
25+
document.getElementById("fullRow").addEventListener('click', function () {
26+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
27+
spreadsheetObj.setRangeReadOnly(true, '2:2', spreadsheetObj.activeSheetIndex);
28+
});
29+
// To make Column A readonly.
30+
document.getElementById("fullCol").addEventListener('click', function () {
31+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
32+
spreadsheetObj.setRangeReadOnly(true, 'A:A', spreadsheetObj.activeSheetIndex);
33+
});
34+
// To make E5 cell readonly.
35+
document.getElementById("singleCell").addEventListener('click', function () {
36+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
37+
spreadsheetObj.setRangeReadOnly(true, 'E5:E5', spreadsheetObj.activeSheetIndex);
38+
});
39+
// To remove readonly.
40+
document.getElementById("removeAll").addEventListener('click', function () {
41+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
42+
spreadsheetObj.setRangeReadOnly(false, '2:2', spreadsheetObj.activeSheetIndex);
43+
spreadsheetObj.setRangeReadOnly(false, 'A:A', spreadsheetObj.activeSheetIndex);
44+
spreadsheetObj.setRangeReadOnly(false, 'E5:E5', spreadsheetObj.activeSheetIndex);
45+
});
46+
47+
</script>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
public IActionResult Open(IFormCollection openRequest)
2+
{
3+
OpenRequest open = new OpenRequest();
4+
open.File = openRequest.Files[0];
5+
return Content(Workbook.Open(open));
6+
}
7+
8+
public void Save(SaveSettings saveSettings)
9+
{
10+
Workbook.Save(saveSettings);
11+
}
12+
13+
public IActionResult Index()
14+
{
15+
List<object> defaultData = new List<object>()
16+
{
17+
new { Item Name= "Casual Shoes", Date= "02/14/2014", Time= "11=34=32 AM", Quantity= "10", Price= "20", Amount= "200", Discount= "1", Profit= "10" },
18+
new { Item Name= "Sports Shoes", Date= "06/11/2014", Time= "05=56=32 AM", Quantity= "20", Price= "30", Amount= "600", Discount= "5", Profit= "50" },
19+
new { Item Name= "Formal Shoes", Date= "07/27/2014", Time= "03=32=44 AM", Quantity= "20", Price= "15", Amount= "300", Discount= "7", Profit= "27" },
20+
new { Item Name= "Sandals & Floaters", Date= "11/21/2014", Time= "06=23=54 AM", Quantity= "15", Price= "20", Amount= "300", Discount= "11", Profit= "67" },
21+
new { Item Name= "Flip- Flops & Slippers", Date= "06/23/2014", Time= "12=43=59 AM", Quantity= "30", Price= "10", Amount= "300", Discount= "10", Profit= "70" },
22+
new { Item Name= "Sneakers", Date= "07/22/2014", Time= "10=55=53 AM", Quantity= "40", Price= "20", Amount= "800", Discount= "13", Profit= "66" },
23+
new { Item Name= "Running Shoes", Date= "02/04/2014", Time= "03=44=34 AM", Quantity= "20", Price= "10", Amount= "200", Discount= "3", Profit= "14" },
24+
new { Item Name= "Loafers", Date= "11/30/2014", Time= "03=12=52 AM", Quantity= "31", Price= "10", Amount= "310", Discount= "6", Profit= "29" },
25+
new { Item Name= "Cricket Shoes", Date= "07/09/2014", Time= "11=32=14 AM", Quantity= "41", Price= "30", Amount= "1210", Discount= "12", Profit= "166" },
26+
new { Item Name= "T-Shirts", Date= "10/31/2014", Time= "12=01=44 AM", Quantity= "50", Price= "10", Amount= "500", Discount= "9", Profit= "55" }
27+
};
28+
ViewBag.DefaultData = defaultData;
29+
return View();
30+
31+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<ejs-button id="fullRow" content="Make row 2 Read Only"></ejs-button>
2+
<ejs-button id="fullCol" content="Make Column A Read Only"></ejs-button>
3+
<ejs-button id="singleCell" content="Make E5 cell Read Only"></ejs-button>
4+
<ejs-button id="removeAll" content="Remove Read Only"></ejs-button>
5+
<ejs-spreadsheet id="spreadsheet" openUrl="Home/Open">
6+
<e-spreadsheet-sheets>
7+
<e-spreadsheet-sheet name="Price Details">
8+
<e-spreadsheet-ranges>
9+
<e-spreadsheet-range dataSource="ViewBag.DefaultData" startCell="A1"></e-spreadsheet-range>
10+
</e-spreadsheet-ranges>
11+
<e-spreadsheet-rows>
12+
<e-spreadsheet-row index="3" isReadOnly="true"></e-spreadsheet-row>
13+
<e-spreadsheet-row index="4">
14+
<e-spreadsheet-cells>
15+
<e-spreadsheet-cell index="5" isReadOnly="true"></e-spreadsheet-cell>
16+
</e-spreadsheet-cells>
17+
</e-spreadsheet-row>
18+
</e-spreadsheet-rows>
19+
<e-spreadsheet-columns>
20+
<e-spreadsheet-column width="130"></e-spreadsheet-column>
21+
<e-spreadsheet-column width="100"></e-spreadsheet-column>
22+
<e-spreadsheet-column width="100" isReadOnly="true"></e-spreadsheet-column>
23+
</e-spreadsheet-columns>
24+
</e-spreadsheet-sheet>
25+
</e-spreadsheet-sheets>
26+
</ejs-spreadsheet>
27+
28+
<script>
29+
30+
// To make row 2 readonly.
31+
document.getElementById("fullRow").addEventListener('click', function () {
32+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
33+
spreadsheetObj.setRangeReadOnly(true, '2:2', spreadsheetObj.activeSheetIndex);
34+
});
35+
// To make Column A readonly.
36+
document.getElementById("fullCol").addEventListener('click', function () {
37+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
38+
spreadsheetObj.setRangeReadOnly(true, 'A:A', spreadsheetObj.activeSheetIndex);
39+
});
40+
// To make E5 cell readonly.
41+
document.getElementById("singleCell").addEventListener('click', function () {
42+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
43+
spreadsheetObj.setRangeReadOnly(true, 'E5:E5', spreadsheetObj.activeSheetIndex);
44+
});
45+
// To remove readonly.
46+
document.getElementById("removeAll").addEventListener('click', function () {
47+
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
48+
spreadsheetObj.setRangeReadOnly(false, '2:2', spreadsheetObj.activeSheetIndex);
49+
spreadsheetObj.setRangeReadOnly(false, 'A:A', spreadsheetObj.activeSheetIndex);
50+
spreadsheetObj.setRangeReadOnly(false, 'E5:E5', spreadsheetObj.activeSheetIndex);
51+
});
52+
</script>

ej2-asp-core-mvc/spreadsheet/keyboard-shortcuts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The keyboard shortcuts supported in the spreadsheet are,
1717
|-------|---------|
1818
| Ctrl + O | Displays dialog to open a file. |
1919
| Ctrl + S / Alt + F2 | Saves the workbook. |
20+
| Ctrl + P | Print the active worksheet when the spreadsheet is in focus. |
2021
| F2 | Enables edit mode. |
2122
| ESC | Cancel edit mode and discard the changes. |
2223
| Backspace and SPACE | Clears content of the active cell and enables edit mode. |
@@ -108,6 +109,7 @@ The keyboard shortcuts supported in the spreadsheet are,
108109
| Shift + Enter | Complete the cell editing and select the cell above in the same column. |
109110
| Tab | Complete the cell editing and select the next cell in the same row. |
110111
| Shift + Tab | Complete the cell editing and select the previous cell in the same row. |
112+
| Shift + F2 | Open the dialog box to add or edit notes for the desired cells. Meanwhile, upon pressing the `Esc` key, the dialog box for notes, when in focus, will save and close. |
111113
| Alt | Focus on the active ribbon tab. |
112114
| Left | Move the focus to the previous items in the ribbon content. |
113115
| Right | Move the focus to the next items in the ribbon content. |

ej2-asp-core-mvc/spreadsheet/open-save.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,30 @@ You can open excel file into a read-only mode by using the [`openComplete`](http
140140
{% endtabs %}
141141
{% endif %}
142142

143+
### Configure JSON deserialization options
144+
145+
Previously, when opening a workbook JSON object into the Spreadsheet using the `openFromJson` method, the entire workbook, including all features specified in the JSON object, was processed and loaded into the Spreadsheet.
146+
147+
Now, you have the option to selectively ignore some features during the opening of the JSON object by configuring deserialization options and passing them as arguments to the `openFromJson` method. This argument is optional, and if not configured, the entire workbook JSON object will be loaded without ignoring any features.
148+
149+
```ts
150+
spreadsheet.openFromJson({ file: file }, { ignoreStyle: true });
151+
```
152+
153+
| Options | Description |
154+
| ----- | ----- |
155+
| onlyValues | If **true**, only the cell values will be loaded. |
156+
| ignoreStyle | If **true**, styles will be excluded when loading the JSON data. |
157+
| ignoreFormula | If **true**, formulas will be excluded when loading the JSON data. |
158+
| ignoreFormat | If **true**, number formats will be excluded when loading the JSON data. |
159+
| ignoreConditionalFormat | If **true**, conditional formatting will be excluded when loading the JSON data. |
160+
| ignoreValidation | If **true**, data validation rules will be excluded when loading the JSON data. |
161+
| ignoreFreezePane | If **true**, freeze panes will be excluded when loading the JSON data. |
162+
| ignoreWrap | If **true**, text wrapping settings will be excluded when loading the JSON data. |
163+
| ignoreChart | If **true**, charts will be excluded when loading the JSON data. |
164+
| ignoreImage | If **true**, images will be excluded when loading the JSON data. |
165+
| ignoreNote | If **true**, notes will be excluded when loading the JSON data. |
166+
143167
### External workbook confirmation dialog
144168

145169
When you open an excel file that contains external workbook references, you will see a confirmation dialog. This dialog allows you to either continue with the file opening or cancel the operation. This confirmation dialog will appear only if you set the `AllowExternalWorkbook` property value to **false** during the open request, as shown below. This prevents the spreadsheet from displaying inconsistent data.
@@ -156,7 +180,7 @@ public IActionResult Open(IFormCollection openRequest)
156180

157181
> This feature is only applicable when importing an Excel file and not when loading JSON data or binding cell data.
158182
159-
![External workbook confirmation dialog](./images/external-reference-dialog-alert%20.png)
183+
![External workbook confirmation dialog](./images/external-reference-dialog-alert.png)
160184

161185
## Supported file formats
162186

@@ -305,6 +329,30 @@ The possible values are:
305329
{% endtabs %}
306330
{% endif %}
307331

332+
### Configure JSON serialization options
333+
334+
Previously, when saving the Spreadsheet as a workbook JSON object using the `saveAsJson` method, the entire workbook with all loaded features were processed and saved as a JSON object.
335+
336+
Now, you have the option to selectively ignore some features while saving the Spreadsheet as a JSON object by configuring serialization options and passing them as arguments to the `saveAsJson` method. This argument is optional, and if not configured, the entire workbook JSON object will be saved without ignoring any features.
337+
338+
```ts
339+
spreadsheet.saveAsJson({ onlyValues: true });
340+
```
341+
342+
| Options | Description |
343+
| ----- | ----- |
344+
| onlyValues | If **true**, includes only the cell values in the JSON output. |
345+
| ignoreStyle | If **true**, excludes styles from the JSON output. |
346+
| ignoreFormula | If **true**, excludes formulas from the JSON output. |
347+
| ignoreFormat | If **true**, excludes number formats from the JSON output. |
348+
| ignoreConditionalFormat | If **true**, excludes conditional formatting from the JSON output. |
349+
| ignoreValidation | If **true**, excludes data validation rules from the JSON output. |
350+
| ignoreFreezePane | If **true**, excludes freeze panes from the JSON output. |
351+
| ignoreWrap | If **true**, excludes text wrapping settings from the JSON output. |
352+
| ignoreChart | If **true**, excludes charts from the JSON output. |
353+
| ignoreImage | If **true**, excludes images from the JSON output. |
354+
| ignoreNote | If **true**, excludes notes from the JSON output. |
355+
308356
### Supported file formats
309357

310358
The following list of Excel file formats are supported in Spreadsheet:

ej2-asp-core-mvc/spreadsheet/protect-sheet.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,31 @@ spreadsheet.setRangeReadOnly(true, 'A:A', 0)
140140

141141
You can make the cells read-only in the cell data binding by setting the `isReadOnly` property to **true** for the respective rows, columns, and cells.
142142

143+
The following example demonstrates how to make rows, columns, and cells read-only without protecting the sheet:
144+
145+
{% if page.publishingplatform == "aspnet-core" %}
146+
147+
{% tabs %}
148+
{% highlight cshtml tabtitle="CSHTML" %}
149+
{% include code-snippet/spreadsheet/read-only/tagHelper %}
150+
{% endhighlight %}
151+
{% highlight c# tabtitle="ReadOnlyController.cs" %}
152+
{% include code-snippet/spreadsheet/read-only/readOnlyController.cs %}
153+
{% endhighlight %}
154+
{% endtabs %}
155+
156+
{% elsif page.publishingplatform == "aspnet-mvc" %}
157+
158+
{% tabs %}
159+
{% highlight razor tabtitle="CSHTML" %}
160+
{% include code-snippet/spreadsheet/read-only/razor %}
161+
{% endhighlight %}
162+
{% highlight c# tabtitle="ReadOnlyController.cs" %}
163+
{% include code-snippet/spreadsheet/read-only/readOnlyController.cs %}
164+
{% endhighlight %}
165+
{% endtabs %}
166+
{% endif %}
167+
143168
## Protect Workbook
144169

145170
Protect workbook feature helps you to protect the workbook so that users cannot insert, delete, rename, hide the sheets in the spreadsheet.

0 commit comments

Comments
 (0)