Skip to content

Commit

Permalink
Merge pull request #3739 from syncfusion-content/EJ2-930405-dev
Browse files Browse the repository at this point in the history
930405: Checked and corrected the Spreadsheet code snippets for ASP .NET MVC documentation.
  • Loading branch information
gobalakrishnans authored Jan 3, 2025
2 parents 64aff00 + f185104 commit 2c4e89e
Show file tree
Hide file tree
Showing 33 changed files with 425 additions and 463 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
this.autoFill('B4:B11', 'B2:B3', 'Down', 'FillFormattingOnly');
this.autoFill('C4:C11', 'C2:C3', 'Down', 'FillWithoutFormatting');
}
document.getElementById("togglebtn").addEventListener('click', function () {
document.getElementById("showfillbtn").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
var showFillOptions = spreadsheetObj.autoFillSettings.showFillOptions;
spreadsheetObj.autoFillSettings.showFillOptions = !showFillOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
document.getElementById("exportBtn").addEventListener('click', function () {
var spreadsheetObj = document.getElementById("spreadsheet").ej2_instances[0];
spreadsheetObj.save({
url: 'Home/Save',
url: 'https://localhost:{{port number}}/Home/Save',
fileName: 'Worksheet',
saveType: 'Xlsx',
}); // Specifies the save URL, file name, file type need to be saved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ public IActionResult Index()
{
List<object> chartData = new List<object>()
{
new { Book= "Classics", Year 2016= "19033", Year 2017= "78453", Year 2018= "24354", Year 2019= "18757", Year 2020= "34343" },
new { Book= "Mystery", Year 2016= "50400", Year 2017= "82311", Year 2018= "131003", Year 2019= "19899", Year 2020= "42200" },
new { Book= "Romance", Year 2016= "18002", Year 2017= "49529", Year 2018= "79567", Year 2019= "12302", Year 2020= "21277" },
new { Book= "Sci-Fi & Fantasy", Year 2016= "10033", Year 2017= "51200", Year 2018= "66211", Year 2019= "12899", Year 2020= "18779" },
new { Book= "Horror", Year 2016= "23454", Year 2017= "78665", Year 2018= "81232", Year 2019= "19888", Year 2020= "20986" }
new { Book= "Classics", Year2016= "19033", Year2017= "78453", Year2018= "24354", Year2019= "18757", Year2020= "34343" },
new { Book= "Mystery", Year2016= "50400", Year2017= "82311", Year2018= "131003", Year2019= "19899", Year2020= "42200" },
new { Book= "Romance", Year2016= "18002", Year2017= "49529", Year2018= "79567", Year2019= "12302", Year2020= "21277" },
new { Book= "Sci-Fi & Fantasy", Year2016= "10033", Year2017= "51200", Year2018= "66211", Year2019= "12899", Year2020= "18779" },
new { Book= "Horror", Year2016= "23454", Year2017= "78665", Year2018= "81232", Year2019= "19888", Year2020= "20986" }
};
ViewBag.DefaultData = chartData;
return View();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ public ActionResult Index()
{
List<object> chartData = new List<object>()
{
new { Book= "Classics", Year 2016= "19033", Year 2017= "78453", Year 2018= "24354", Year 2019= "18757", Year 2020= "34343" },
new { Book= "Mystery", Year 2016= "50400", Year 2017= "82311", Year 2018= "131003", Year 2019= "19899", Year 2020= "42200" },
new { Book= "Romance", Year 2016= "18002", Year 2017= "49529", Year 2018= "79567", Year 2019= "12302", Year 2020= "21277" },
new { Book= "Sci-Fi & Fantasy", Year 2016= "10033", Year 2017= "51200", Year 2018= "66211", Year 2019= "12899", Year 2020= "18779" },
new { Book= "Horror", Year 2016= "23454", Year 2017= "78665", Year 2018= "81232", Year 2019= "19888", Year 2020= "20986" }
new { Book= "Classics", Year2016= "19033", Year2017= "78453", Year2018= "24354", Year2019= "18757", Year2020= "34343" },
new { Book= "Mystery", Year2016= "50400", Year2017= "82311", Year2018= "131003", Year2019= "19899", Year2020= "42200" },
new { Book= "Romance", Year2016= "18002", Year2017= "49529", Year2018= "79567", Year2019= "12302", Year2020= "21277" },
new { Book= "Sci-Fi & Fantasy", Year2016= "10033", Year2017= "51200", Year2018= "66211", Year2019= "12899", Year2020= "18779" },
new { Book= "Horror", Year2016= "23454", Year2017= "78665", Year2018= "81232", Year2019= "19888", Year2020= "20986" }
};
ViewBag.DefaultData = chartData;
return View();
Expand Down
2 changes: 1 addition & 1 deletion ej2-asp-core-mvc/code-snippet/spreadsheet/clear/tagHelper
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script>

function created() {
this.cellFormat({ fontWeight: 'bold', fontSize: '12pt'}, 'A1:E1');
this.cellFormat({ fontWeight: 'bold', fontSize: '12pt'}, 'A1:F1');
this.cellFormat({ color: '#10c469' }, 'B1:B10');
}

Expand Down
3 changes: 0 additions & 3 deletions ej2-asp-core-mvc/code-snippet/spreadsheet/clipboard/tagHelper
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
</ejs-spreadsheet>

<script>
document.getElementById("cutBtn").addEventListener('click', cut);
document.getElementById("copyBtn").addEventListener('click', copy);
document.getElementById("pasteBtn").addEventListener('click', paste);
function createHandler() {
//Applies format to specified range
this.cellFormat({ fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' }, 'A1:G1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<e-spreadsheet-range dataSource="ViewBag.DefaultData"></e-spreadsheet-range>
</e-spreadsheet-ranges>
<e-spreadsheet-conditionalformats>
<e-spreadsheet-conditionalformat type= "GreaterThan", cFColor= "RedFT", value= "700", range= 'B2:B9'>
<e-spreadsheet-conditionalformat type= "GreaterThan", cFColor= "RedFT", value= "700", range= 'B2:B9'></e-spreadsheet-conditionalformat>
<e-spreadsheet-conditionalformat type= "Bottom10Items", cFColor= "YellowFT", value= '4', range= 'C2:C9'></e-spreadsheet-conditionalformat>
<e-spreadsheet-conditionalformat type= "BlueDataBar", range= 'D2:D9'></e-spreadsheet-conditionalformat>
</e-spreadsheet-conditionalformats>
Expand All @@ -26,4 +26,5 @@
format: { style: { color: '#ffffff', backgroundColor: '#009999', fontWeight: 'bold'}}, range: 'F2:F9' });
this.conditionalFormat({ type: 'Bottom10Items', value: '1',
format: { style: { color: '#ffffff', backgroundColor: '#c68d53', fontWeight: 'bold'}}, range: 'G2:G9' });
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
<e-spreadsheet-cell value="1,00,095.00"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-columns>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="106"></e-spreadsheet-column>
<e-spreadsheet-column width="98"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="81"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-rows>
<e-spreadsheet-columns>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="106"></e-spreadsheet-column>
<e-spreadsheet-column width="98"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="81"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-sheet>
</e-spreadsheet-sheets>
</ejs-spreadsheet>
Expand Down
42 changes: 21 additions & 21 deletions ej2-asp-core-mvc/code-snippet/spreadsheet/data-validation/tagHelper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ejs-spreadsheet id="spreadsheet" created="created" showFormulaBar="false">
<ejs-spreadsheet id="spreadsheet" created="created" showFormulaBar="false">
<e-spreadsheet-sheets>
<e-spreadsheet-sheet name="PriceDetails">
<e-spreadsheet-rows>
Expand Down Expand Up @@ -27,7 +27,7 @@
</e-spreadsheet-cell>
<e-spreadsheet-cell value="Total Price">
<e-spreadsheet-cellstyle fontWeight="Bold" textAlign="Center"></e-spreadsheet-cellstyle>
</e-spreadsheet-cell
</e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-row>
Expand All @@ -45,7 +45,7 @@
</e-spreadsheet-cell>
<e-spreadsheet-cell value="04/11/2019"></e-spreadsheet-cell>
<e-spreadsheet-cell value="11:34:32 AM"></e-spreadsheet-cell>
<e-spreadsheet-cell value="1,45,000.00"></e-spreadsheet-cell
<e-spreadsheet-cell value="1,45,000.00"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-row>
Expand All @@ -63,7 +63,7 @@
</e-spreadsheet-cell>
<e-spreadsheet-cell value="04/11/2019"></e-spreadsheet-cell>
<e-spreadsheet-cell value="11:34:32 AM"></e-spreadsheet-cell>
<e-spreadsheet-cell value="1,45,000.00"></e-spreadsheet-cell
<e-spreadsheet-cell value="1,45,000.00"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-row>
Expand All @@ -81,7 +81,7 @@
</e-spreadsheet-cell>
<e-spreadsheet-cell value="06/25/2019"></e-spreadsheet-cell>
<e-spreadsheet-cell value="01:30:11 PM"></e-spreadsheet-cell>
<e-spreadsheet-cell value="545.00"></e-spreadsheet-cell
<e-spreadsheet-cell value="545.00"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-row>
Expand All @@ -99,32 +99,32 @@
</e-spreadsheet-cell>
<e-spreadsheet-cell value="09/22/2019"></e-spreadsheet-cell>
<e-spreadsheet-cell value="12:30:02 PM"></e-spreadsheet-cell>
<e-spreadsheet-cell value="1,00,095.00"></e-spreadsheet-cell
<e-spreadsheet-cell value="1,00,095.00"></e-spreadsheet-cell>
</e-spreadsheet-cells>
</e-spreadsheet-row>
<e-spreadsheet-columns>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="106"></e-spreadsheet-column>
<e-spreadsheet-column width="98"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="86"></e-spreadsheet-column>
<e-spreadsheet-column width="107"></e-spreadsheet-column>
<e-spreadsheet-column width="81"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-rows>
<e-spreadsheet-columns>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="106"></e-spreadsheet-column>
<e-spreadsheet-column width="98"></e-spreadsheet-column>
<e-spreadsheet-column width="88"></e-spreadsheet-column>
<e-spreadsheet-column width="86"></e-spreadsheet-column>
<e-spreadsheet-column width="107"></e-spreadsheet-column>
<e-spreadsheet-column width="81"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-sheet>
</e-spreadsheet-sheets>
</ejs-spreadsheet>

<script>
function created() {
//Add Data Validation to range.
this.addDataValidation({ type: 'TextLength', Operator: 'LessThanOrEqualTo', Value1: '4' }, 'A2:A5');
this.addDataValidation({ type: 'WholeNumber', Operator: 'NotEqualTo', Value1: '1' }, 'B2:B5');
this.addDataValidation({ type: 'Date', Operator: 'NotEqualTo', Value1: '04/11/2019' }, 'F2:F5');
this.addDataValidation({ type: 'Time', Operator: 'Between', Value1: '10:00:00 AM', value2: '11:00:00 AM' }, 'G2:G5');
this.addDataValidation({ type: 'Decimal', Operator: 'LessThan', Value1: '100000.00' }, 'H2:H5');
this.addDataValidation({ type: 'TextLength', operator: 'LessThanOrEqualTo', value1: '4' }, 'A2:A5');
this.addDataValidation({ type: 'WholeNumber', operator: 'NotEqualTo', value1: '1' }, 'B2:B5');
this.addDataValidation({ type: 'Date', operator: 'NotEqualTo', value1: '04/11/2019' }, 'F2:F5');
this.addDataValidation({ type: 'Time', operator: 'Between', value1: '10:00:00 AM', value2: '11:00:00 AM' }, 'G2:G5');
this.addDataValidation({ type: 'Decimal', operator: 'LessThan', value1: '100000.00' }, 'H2:H5');
//Highlight Invalid Data.
this.addInvalidHighlight('A1:H5');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ejs-spreadsheet id="spreadsheet" created="created" showFormulaBar="false" allowDelete="false" showRibbon="false">
<ejs-spreadsheet id="spreadsheet" created="created" showFormulaBar="false" allowDelete="true" showRibbon="false">
<e-spreadsheet-sheets>
<e-spreadsheet-sheet name="Sheet1">
<e-spreadsheet-ranges>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
log.insertBefore(span, log.firstChild);
}

function dataSourceChanged() {
this.appendElement("Data source changed with" + "<b>&nbsp;" + args.action + "</b> action<hr>"
function dataSourceChanged(args) {
appendElement("Data source changed with" + "<b>&nbsp;" + args.action + "</b> action<hr>"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<script>
function createdHandler() {
//To enable / disable context menu items.
this.spreadsheet.enableContextMenuItems(['Rename'], false, false); // Contextmenu Items that needs to be enabled / disabled, Set true / false to enable / disable the menu items, Set true if the given text is a unique id.
this.enableContextMenuItems(['Rename'], false, false); // Contextmenu Items that needs to be enabled / disabled, Set true / false to enable / disable the menu items, Set true if the given text is a unique id.
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script>

function ContextMenuBeforeOpen(args) {
function contextMenuBeforeOpen(args) {
if (ejs.base.closest(args.event.target, '.e-sheet-content')) {
console.log('Cell Context Menu');
} else if (ejs.base.closest(args.event.target, '.e-colhdr-table')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@
function loadCultureFiles (localeOptions) {
for (var locale = 0; locale < localeOptions.length; locale++) {
var files = ['ca-gregorian', 'currencies', 'numbers', 'timeZoneNames', 'numberingSystems'];
var loader = ej.base.loadCldr;
var loadCulture = function (fileName) {
var url = './cldr-data/' + (fileName === 'numberingSystems' ? '' : (localeOptions[locale] + '/')) + fileName + '.json';
var val;
var url = location.origin + '/../cldr-data/' + (fileName === 'numberingSystems' ? 'supplemental/' : ('main/' + (localeOptions[locale] + '/'))) + fileName + '.json';
var ajax = new ej.base.Ajax(url, 'GET', false);
ajax.onSuccess = (value) => ej.base.loadCldr(JSON.parse(value));
ajax.onSuccess = function (value) {
val = value;
};
ajax.send();
loader(JSON.parse(val));
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(files[prop]);
Expand Down
Loading

0 comments on commit 2c4e89e

Please sign in to comment.