Skip to content

DOCINFRA-2341_merged_using_automation #3092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions ej2-asp-core-mvc/code-snippet/spreadsheet/read-only/razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@Html.EJS().Button("fullRow").Content("Make row 2 Read Only").Render();
@Html.EJS().Button("fullCol").Content("Make Column A Read Only").Render();
@Html.EJS().Button("singleCell").Content("Make E5 cell Read Only").Render();
@Html.EJS().Button("removeAll").Content("Remove Read Only").Render();
@Html.EJS().Spreadsheet("spreadsheet").Sheets(sheet => {
sheet.Name("Price Details").Ranges(ranges => {
ranges.DataSource((IEnumerable<object>)ViewBag.DefaultData).StartCell("A1").Add();
}).Rows(row =>
{
row.Index(3).IsReadOnly(true).Add();
row.Index(4).Cells(cell =>
{
cell.Index(5).IsReadOnly(true).Add();
}).Add();
}).Columns(column => {
column.Width(130).Add();
column.Width(100).Add();
column.Width(100).IsReadOnly(true).Add();
}).Add();
}).Render()

<script>

// To make row 2 readonly.
document.getElementById("fullRow").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, '2:2', spreadsheetObj.activeSheetIndex);
});
// To make Column A readonly.
document.getElementById("fullCol").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, 'A:A', spreadsheetObj.activeSheetIndex);
});
// To make E5 cell readonly.
document.getElementById("singleCell").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, 'E5:E5', spreadsheetObj.activeSheetIndex);
});
// To remove readonly.
document.getElementById("removeAll").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(false, '2:2', spreadsheetObj.activeSheetIndex);
spreadsheetObj.setRangeReadOnly(false, 'A:A', spreadsheetObj.activeSheetIndex);
spreadsheetObj.setRangeReadOnly(false, 'E5:E5', spreadsheetObj.activeSheetIndex);
});

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public IActionResult Open(IFormCollection openRequest)
{
OpenRequest open = new OpenRequest();
open.File = openRequest.Files[0];
return Content(Workbook.Open(open));
}

public void Save(SaveSettings saveSettings)
{
Workbook.Save(saveSettings);
}

public IActionResult Index()
{
List<object> defaultData = new List<object>()
{
new { Item Name= "Casual Shoes", Date= "02/14/2014", Time= "11=34=32 AM", Quantity= "10", Price= "20", Amount= "200", Discount= "1", Profit= "10" },
new { Item Name= "Sports Shoes", Date= "06/11/2014", Time= "05=56=32 AM", Quantity= "20", Price= "30", Amount= "600", Discount= "5", Profit= "50" },
new { Item Name= "Formal Shoes", Date= "07/27/2014", Time= "03=32=44 AM", Quantity= "20", Price= "15", Amount= "300", Discount= "7", Profit= "27" },
new { Item Name= "Sandals & Floaters", Date= "11/21/2014", Time= "06=23=54 AM", Quantity= "15", Price= "20", Amount= "300", Discount= "11", Profit= "67" },
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" },
new { Item Name= "Sneakers", Date= "07/22/2014", Time= "10=55=53 AM", Quantity= "40", Price= "20", Amount= "800", Discount= "13", Profit= "66" },
new { Item Name= "Running Shoes", Date= "02/04/2014", Time= "03=44=34 AM", Quantity= "20", Price= "10", Amount= "200", Discount= "3", Profit= "14" },
new { Item Name= "Loafers", Date= "11/30/2014", Time= "03=12=52 AM", Quantity= "31", Price= "10", Amount= "310", Discount= "6", Profit= "29" },
new { Item Name= "Cricket Shoes", Date= "07/09/2014", Time= "11=32=14 AM", Quantity= "41", Price= "30", Amount= "1210", Discount= "12", Profit= "166" },
new { Item Name= "T-Shirts", Date= "10/31/2014", Time= "12=01=44 AM", Quantity= "50", Price= "10", Amount= "500", Discount= "9", Profit= "55" }
};
ViewBag.DefaultData = defaultData;
return View();

}
52 changes: 52 additions & 0 deletions ej2-asp-core-mvc/code-snippet/spreadsheet/read-only/tagHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<ejs-button id="fullRow" content="Make row 2 Read Only"></ejs-button>
<ejs-button id="fullCol" content="Make Column A Read Only"></ejs-button>
<ejs-button id="singleCell" content="Make E5 cell Read Only"></ejs-button>
<ejs-button id="removeAll" content="Remove Read Only"></ejs-button>
<ejs-spreadsheet id="spreadsheet" openUrl="Home/Open">
<e-spreadsheet-sheets>
<e-spreadsheet-sheet name="Price Details">
<e-spreadsheet-ranges>
<e-spreadsheet-range dataSource="ViewBag.DefaultData" startCell="A1"></e-spreadsheet-range>
</e-spreadsheet-ranges>
<e-spreadsheet-rows>
<e-spreadsheet-row index="3" isReadOnly="true"></e-spreadsheet-row>
<e-spreadsheet-row index="4">
<e-spreadsheet-cells>
<e-spreadsheet-cell index="5" isReadOnly="true"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
</e-spreadsheet-rows>
<e-spreadsheet-columns>
<e-spreadsheet-column width="130"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100" isReadOnly="true"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-sheet>
</e-spreadsheet-sheets>
</ejs-spreadsheet>

<script>

// To make row 2 readonly.
document.getElementById("fullRow").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, '2:2', spreadsheetObj.activeSheetIndex);
});
// To make Column A readonly.
document.getElementById("fullCol").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, 'A:A', spreadsheetObj.activeSheetIndex);
});
// To make E5 cell readonly.
document.getElementById("singleCell").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(true, 'E5:E5', spreadsheetObj.activeSheetIndex);
});
// To remove readonly.
document.getElementById("removeAll").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.setRangeReadOnly(false, '2:2', spreadsheetObj.activeSheetIndex);
spreadsheetObj.setRangeReadOnly(false, 'A:A', spreadsheetObj.activeSheetIndex);
spreadsheetObj.setRangeReadOnly(false, 'E5:E5', spreadsheetObj.activeSheetIndex);
});
</script>
2 changes: 2 additions & 0 deletions ej2-asp-core-mvc/spreadsheet/keyboard-shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The keyboard shortcuts supported in the spreadsheet are,
|-------|---------|
| Ctrl + O | Displays dialog to open a file. |
| Ctrl + S / Alt + F2 | Saves the workbook. |
| Ctrl + P | Print the active worksheet when the spreadsheet is in focus. |
| F2 | Enables edit mode. |
| ESC | Cancel edit mode and discard the changes. |
| Backspace and SPACE | Clears content of the active cell and enables edit mode. |
Expand Down Expand Up @@ -108,6 +109,7 @@ The keyboard shortcuts supported in the spreadsheet are,
| Shift + Enter | Complete the cell editing and select the cell above in the same column. |
| Tab | Complete the cell editing and select the next cell in the same row. |
| Shift + Tab | Complete the cell editing and select the previous cell in the same row. |
| 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. |
| Alt | Focus on the active ribbon tab. |
| Left | Move the focus to the previous items in the ribbon content. |
| Right | Move the focus to the next items in the ribbon content. |
Expand Down
50 changes: 49 additions & 1 deletion ej2-asp-core-mvc/spreadsheet/open-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,30 @@ You can open excel file into a read-only mode by using the [`openComplete`](http
{% endtabs %}
{% endif %}

### Configure JSON deserialization options

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.

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.

```ts
spreadsheet.openFromJson({ file: file }, { ignoreStyle: true });
```

| Options | Description |
| ----- | ----- |
| onlyValues | If **true**, only the cell values will be loaded. |
| ignoreStyle | If **true**, styles will be excluded when loading the JSON data. |
| ignoreFormula | If **true**, formulas will be excluded when loading the JSON data. |
| ignoreFormat | If **true**, number formats will be excluded when loading the JSON data. |
| ignoreConditionalFormat | If **true**, conditional formatting will be excluded when loading the JSON data. |
| ignoreValidation | If **true**, data validation rules will be excluded when loading the JSON data. |
| ignoreFreezePane | If **true**, freeze panes will be excluded when loading the JSON data. |
| ignoreWrap | If **true**, text wrapping settings will be excluded when loading the JSON data. |
| ignoreChart | If **true**, charts will be excluded when loading the JSON data. |
| ignoreImage | If **true**, images will be excluded when loading the JSON data. |
| ignoreNote | If **true**, notes will be excluded when loading the JSON data. |

### External workbook confirmation dialog

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.
Expand All @@ -156,7 +180,7 @@ public IActionResult Open(IFormCollection openRequest)

> This feature is only applicable when importing an Excel file and not when loading JSON data or binding cell data.

![External workbook confirmation dialog](./images/external-reference-dialog-alert%20.png)
![External workbook confirmation dialog](./images/external-reference-dialog-alert.png)

## Supported file formats

Expand Down Expand Up @@ -305,6 +329,30 @@ The possible values are:
{% endtabs %}
{% endif %}

### Configure JSON serialization options

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.

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.

```ts
spreadsheet.saveAsJson({ onlyValues: true });
```

| Options | Description |
| ----- | ----- |
| onlyValues | If **true**, includes only the cell values in the JSON output. |
| ignoreStyle | If **true**, excludes styles from the JSON output. |
| ignoreFormula | If **true**, excludes formulas from the JSON output. |
| ignoreFormat | If **true**, excludes number formats from the JSON output. |
| ignoreConditionalFormat | If **true**, excludes conditional formatting from the JSON output. |
| ignoreValidation | If **true**, excludes data validation rules from the JSON output. |
| ignoreFreezePane | If **true**, excludes freeze panes from the JSON output. |
| ignoreWrap | If **true**, excludes text wrapping settings from the JSON output. |
| ignoreChart | If **true**, excludes charts from the JSON output. |
| ignoreImage | If **true**, excludes images from the JSON output. |
| ignoreNote | If **true**, excludes notes from the JSON output. |

### Supported file formats

The following list of Excel file formats are supported in Spreadsheet:
Expand Down
25 changes: 25 additions & 0 deletions ej2-asp-core-mvc/spreadsheet/protect-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,31 @@ spreadsheet.setRangeReadOnly(true, 'A:A', 0)

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.

The following example demonstrates how to make rows, columns, and cells read-only without protecting the sheet:

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/spreadsheet/read-only/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="ReadOnlyController.cs" %}
{% include code-snippet/spreadsheet/read-only/readOnlyController.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/spreadsheet/read-only/razor %}
{% endhighlight %}
{% highlight c# tabtitle="ReadOnlyController.cs" %}
{% include code-snippet/spreadsheet/read-only/readOnlyController.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}

## Protect Workbook

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