Last active
April 6, 2022 08:26
-
-
Save aspose-cells-gists/7c644a93d33d24299a618c1dda1a2385 to your computer and use it in GitHub Desktop.
Aspose.Cells.GridWeb for .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This Gist contains code example snippets for Aspose.Cells.GridWeb for .NET. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| ----------------------------------------------- | |
| AddCustomServerSideFunctionValidation.aspx | |
| ----------------------------------------------- | |
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCustomServerSideFunctionValidation.aspx.cs" Inherits="Aspose.Cells.GridWeb.Examples.AddCustomServerSideFunctionValidation" %> | |
| <%@ Register TagPrefix="acw" Namespace="Aspose.Cells.GridWeb" Assembly="Aspose.Cells.GridWeb" %> | |
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head runat="server"> | |
| <link rel="stylesheet" href="/Scripts/jquery-ui.css" /> | |
| <script src="/Scripts/jquery-2.1.1.js"></script> | |
| <script src="/Scripts/jquery-ui.js"></script> | |
| <script type="text/javascript"> | |
| var lastselectvalue = null; | |
| var localvalue = {}; | |
| function myCellSelect(cell) { | |
| //Get the selected cell. | |
| var value = this.getCellValueByCell(cell); | |
| //Get the value to store. | |
| lastselectvalue = value; | |
| var key = this.acttab + "_" + this.getCellRow(cell) + "_" + this.getCellColumn(cell); | |
| //Store the respective cell's value. | |
| localvalue[key] = lastselectvalue; | |
| console.log("OnCellSelect: value:" + value + " row:" + this.getCellRow(cell) + ",col:" + this.getCellColumn(cell)); | |
| console.log("Last selected value:" + lastselectvalue); | |
| } | |
| function ValidationErrorClientFunctionCallback(cell, msg) { | |
| //Get the error message string. | |
| var errmsg1 = getattr(cell, "errmsg"); | |
| //Show the error message in the client dialog. | |
| alert(errmsg1); | |
| //Showing an alert message where "this" refers to GridWeb | |
| alert(this.id + "----> " + msg + " Previous value will be restored."); | |
| $("#errmsg").text(msg); | |
| console.log("Selected cell:" + " row:" + this.getCellRow(cell) + ",col:" + this.getCellColumn(cell)); | |
| //Get the GridWeb. | |
| var who = this; | |
| //Restore to valid value/previous value. | |
| who.setValid(cell); | |
| var key = this.acttab + "_" + this.getCellRow(cell) + "_" + this.getCellColumn(cell); | |
| lastselectvalue = localvalue[key]; | |
| setInnerText(cell.children[0], lastselectvalue); | |
| } | |
| </script> | |
| <title>Add Custom Server-side Function Validation</title> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div> | |
| <div> | |
| <b>GridWeb Version: </b> | |
| <asp:Label ID="lblVersion" runat="server" Text="Label"></asp:Label> | |
| <br /> | |
| <acw:GridWeb ID="GridWeb1" runat="server" OnCellSelectedClientFunction="myCellSelect" Width="44%" Height="384px" ShowLoading="true" XhtmlMode="true" | |
| PresetStyle="Standard" EnableAJAX="true" EnableAsync="true" RenderHiddenRow="true" MaxColumn="15" MaxRow="21"> | |
| </acw:GridWeb> | |
| </div> | |
| </div> | |
| <span id="errmsg" style="color: red;"></span> | |
| </form> | |
| </body> | |
| </html> | |
| ----------------------------------------------- | |
| AddCustomServerSideFunctionValidation.aspx.cs | |
| ----------------------------------------------- | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| using Aspose.Cells.GridWeb; | |
| using Aspose.Cells.GridWeb.Data; | |
| namespace Aspose.Cells.GridWeb.Examples | |
| { | |
| class MyServerValidation : GridCustomServerValidation | |
| { | |
| public string Validate(GridWorksheet sheet, int row, int col, string value) | |
| { | |
| if ((row == 1) || (row == 2)) | |
| { | |
| return "Value Not Passed!"; | |
| } | |
| else | |
| { | |
| return string.Empty; | |
| } | |
| } | |
| } | |
| public partial class AddCustomServerSideFunctionValidation : System.Web.UI.Page | |
| { | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (!IsPostBack && !this.GridWeb1.IsPostBack) | |
| { | |
| lblVersion.Text = GridWeb.GetVersion(); | |
| //Input values to B2:C3 cells in the active worksheet. | |
| GridWeb1.ActiveSheet.Cells["B2"].PutValue("This"); | |
| GridWeb1.ActiveSheet.Cells["C2"].PutValue("cannot"); | |
| GridWeb1.ActiveSheet.Cells["B3"].PutValue("be"); | |
| GridWeb1.ActiveSheet.Cells["C3"].PutValue("changed"); | |
| //Get the validations of the active sheet. | |
| var gridValidationCollection = GridWeb1.ActiveSheet.Validations; | |
| //Add data validation to range/area: B2:C3 | |
| GridValidation gv = gridValidationCollection.Add(new GridCellArea(1, 1, 2, 2)); | |
| //Set the validation type to custom server function. | |
| gv.ValidationType = GridValidationType.CustomServerFunction; | |
| //Set the server validation class which implements the GridCustomServerValidation interface. | |
| gv.ServerValidation = new MyServerValidation(); | |
| //Set the client validation function (written in JavaScript on client-side). | |
| //This function is compulsory to validate the data on client end on callback. | |
| gv.ClientValidationFunction = "ValidationErrorClientFunctionCallback"; | |
| //Set the error message string. | |
| gv.ErrorMessage = "Error found! You cannot change this value."; | |
| //Set the error title. | |
| gv.ErrorTitle = "Error"; | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| private class GridWebCustomCalculationEngine : GridAbstractCalculationEngine | |
| { | |
| public override void Calculate(GridCalculationData data) | |
| { | |
| // Calculate MYTESTFUNC() with your own logic. i.e Multiply MYTESTFUNC() parameter with 2 so MYTESTFUNC(3.0) = 6 | |
| if ("MYTESTFUNC".Equals(data.FunctionName.ToUpper())) | |
| { | |
| data.CalculatedValue = (decimal)(2.0 * (double)data.GetParamValue(0)); | |
| } | |
| } | |
| } | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (Page.IsPostBack == false && GridWeb1.IsPostBack == false) | |
| { | |
| // Assign your own custom calculation engine to GridWeb | |
| GridWeb1.CustomCalculationEngine = new GridWebCustomCalculationEngine(); | |
| // Access the active worksheet and add your custom function in cell B3 | |
| GridWorksheet sheet = GridWeb1.ActiveSheet; | |
| GridCell cell = sheet.Cells["B3"]; | |
| cell.Formula = "=MYTESTFUNC(9.0)"; | |
| // Calculate the GridWeb formula | |
| GridWeb1.CalculateFormula(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| GridWeb1.EnableAsync = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <button type="button" onclick="ReadGridWebCells()">Click me</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <script type="text/javascript"> | |
| function ReadGridWebCells() { | |
| // Access GridWeb instance and cells array | |
| var gridwebins = gridwebinstance.get("<%=GridWeb1.ClientID%>"); | |
| var cells = gridwebins.getCellsArray(); | |
| // Log cell name, values, row & column indexes in console | |
| for (var j = 0; j < cells.length; j++) | |
| { | |
| var cellInfo = j + ":" + gridwebins.getCellName(cells[j]) + ","; | |
| cellInfo += "value is:" + gridwebins.getCellValueByCell(cells[j]) + " ,"; | |
| cellInfo += "row:" + gridwebins.getCellRow(cells[j]) + ","; | |
| cellInfo += "col:" + gridwebins.getCellColumn(cells[j]); | |
| console.log(cellInfo); | |
| } | |
| } | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access cell A1 of first gridweb worksheet | |
| GridCell cellA1 = GridWeb1.WorkSheets[0].Cells["A1"]; | |
| // Access cell style and set its number format to 10 which is a Percentage 0.00% format | |
| GridTableItemStyle st = cellA1.Style; | |
| st.NumberType = 10; | |
| cellA1.Style = st; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Gets the web application's path. | |
| string path = (this.Master as Site).GetDataDir(); | |
| // Clear the sheets | |
| GridWeb1.WorkSheets.Clear(); | |
| // Load the file | |
| GridWeb1.ImportExcelFile(path + "\\Articles\\source.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| GridWeb1.SessionStorePath = "mytempdir/session"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access GridWeb control | |
| var gridinstance = document.getElementById('<%=GridWeb1.ClientID%>'); | |
| // Set selected range | |
| var range = {}; range.startRow = 1; range.startCol = 1; range.endRow = 2; range.endCol = 2; | |
| gridinstance.setSelectRange(range); | |
| // Get selected range | |
| var selectrange = gridinstance.getSelectRange(); | |
| alert("Start Row:" + selectrange.startRow); | |
| alert("Start Column:" + selectrange.startCol); | |
| alert("End Row:" + selectrange.endRow); | |
| alert("End Column:" + selectrange.endCol); | |
| // Clear selection | |
| gridinstance.clearSelections(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access first worksheet of gridweb and cell A1 | |
| GridWorksheet sheet = GridWeb1.WorkSheets[0]; | |
| GridCell cellA1 = sheet.Cells["A1"]; | |
| // Access hyperlink of cell A1 if it contains any | |
| GridHyperlink cellHyperlink = sheet.Hyperlinks.GetHyperlink(cellA1); | |
| if (cellHyperlink == null) | |
| { | |
| Label1.Text = "Cell A1 does not have any hyperlink"; | |
| } | |
| else | |
| { | |
| // Access hyperlink properties e.g. address | |
| string hyperlinkAddress = cellHyperlink.Address; | |
| Label1.Text = "Address of hyperlink in cell A1 :" + hyperlinkAddress; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "A1" cell of the worksheet | |
| GridCell cell = sheet.Cells["A1"]; | |
| // Display cell name and value | |
| Label1.Text += "Cell Value of " + cell.Name +" is " + cell.StringValue + "<br/>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "B1" cell of the worksheet using its row and column indices | |
| GridCell cell = sheet.Cells[0, 1]; | |
| // Display cell name and value | |
| Label1.Text += "Cell Value of " + cell.Name +" is " + cell.StringValue + "<br/>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Access "B1" cell and add some text | |
| GridCell cell = sheet.Cells[0, 1]; | |
| cell.PutValue("Date (yyyy-mm-dd):"); | |
| // Access "C1" cell and add to it custom expression validation to accept dates in yyyy-mm-dd format | |
| cell = sheet.Cells[0, 2]; | |
| var validation = cell.CreateValidation(GridValidationType.CustomExpression, true); | |
| validation.RegEx = @"\d{4}-\d{2}-\d{2}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access first worksheet | |
| GridWorksheet sheet = GridWeb1.WorkSheets[0]; | |
| // Access cell B3 | |
| GridCell cell = sheet.Cells["B3"]; | |
| // Add validation inside the gridcell | |
| // Any value which is not between 20 and 40 will cause error in a gridcell | |
| GridValidation val = cell.CreateValidation(GridValidationType.WholeNumber, true); | |
| val.Formula1 = "=20"; | |
| val.Formula2 = "=40"; | |
| val.Operator = GridOperatorType.Between; | |
| val.ShowError = true; | |
| val.ShowInput = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Access "B1" cell and add some text | |
| GridCell cell = sheet.Cells[0, 1]; | |
| cell.PutValue("Select Degree:"); | |
| // Accessing "C1" cell | |
| cell = sheet.Cells[0, 2]; | |
| // Creating DropDownList validation for the "C1" cell | |
| var validation = cell.CreateValidation(GridValidationType.DropDownList, true); | |
| // Adding values to DropDownList validation | |
| var values = new System.Collections.Specialized.StringCollection(); | |
| values.Add("Bachelor"); | |
| values.Add("Master"); | |
| values.Add("Doctor"); | |
| validation.ValueList = values; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Adding a bit complex formula to "A1" cell | |
| sheet1.Cells["B6"].Formula = "=(SUM(A1:A5)/AVERAGE(B1:B5))-Sheet2!B1"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Putting some values to cells | |
| sheet.Cells["A1"].PutValue("1st Value"); | |
| sheet.Cells["A2"].PutValue("2nd Value"); | |
| sheet.Cells["A3"].PutValue("Sum"); | |
| sheet.Cells["B1"].PutValue(125.56); | |
| sheet.Cells["B2"].PutValue(23.93); | |
| // Adding a simple formula to "B3" cell | |
| sheet.Cells["B3"].Formula = "=SUM(B1:B2)"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Calculating all formulas added in worksheets | |
| GridWeb1.WorkSheets.CalculateFormula(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Access "B1" cell and add some text | |
| GridCell cell = sheet.Cells[0, 1]; | |
| cell.PutValue("Select Course:"); | |
| // Accessing "C1" cell | |
| cell = sheet.Cells[0, 2]; | |
| // Creating List validation for the "C1" cell | |
| var validation = cell.CreateValidation(GridValidationType.List, true); | |
| // Adding values to List validation | |
| var values = new System.Collections.Specialized.StringCollection(); | |
| values.Add("Fortran"); | |
| values.Add("Pascal"); | |
| values.Add("C++"); | |
| values.Add("Visual Basic"); | |
| values.Add("Java"); | |
| values.Add("C#"); | |
| validation.ValueList = values; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active and resize first row and column | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| sheet.Cells.Clear(); | |
| sheet.Cells.SetColumnWidth(0, 50); | |
| sheet.Cells.SetRowHeight(0, 40); | |
| // Accessing a specific cell of the worksheet | |
| GridCell cell = sheet.Cells["A1"]; | |
| var style = cell.Style; | |
| // Setting the border style, width and color | |
| style.BorderStyle = BorderStyle.Solid; | |
| style.BorderWidth = new Unit(2, UnitType.Pixel); | |
| style.BorderColor = Color.Blue; | |
| // Set the cell style | |
| cell.CopyStyle(style); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active and resize first row and column | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| sheet.Cells.Clear(); | |
| sheet.Cells.SetColumnWidth(0, 50); | |
| sheet.Cells.SetRowHeight(0, 40); | |
| // Accessing a specific cell of the worksheet | |
| GridCell cell = sheet.Cells["A1"]; | |
| // Inserting a value in cell A1 | |
| cell.PutValue("Aspose.Cells.GridWeb"); | |
| var style = cell.Style; | |
| // Setting font, color and alignment of cell | |
| style.Font.Size = new FontUnit("12pt"); | |
| style.Font.Bold = true; | |
| style.ForeColor = Color.Blue; | |
| style.BackColor = Color.Aqua; | |
| style.HorizontalAlign = HorizontalAlign.Center; | |
| // Set the cell style | |
| cell.CopyStyle(style); | |
| sheet.AutoFitColumn(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| sheet.Cells.Clear(); | |
| sheet.Cells.SetColumnWidth(0, 50); | |
| sheet.Cells.SetRowHeight(0, 40); | |
| // Putting values to cells | |
| sheet.Cells["A1"].PutValue("Currency1 Number Format"); | |
| sheet.Cells["A2"].PutValue("Custom Number Format"); | |
| sheet.Cells["B1"].PutValue(7800); | |
| sheet.Cells["B2"].PutValue(2500); | |
| // Setting the number format of "B1" cell to Currency1 | |
| sheet.Cells["B1"].SetNumberType((int)NumberType.Currency1); | |
| // Setting the custom number format of "B2" cell | |
| sheet.Cells["B2"].SetCustom("#,##0.0000"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| sheet.Cells.Clear(); | |
| // Creating an instance of WebBorderStyle | |
| WebBorderStyle bstyle = new WebBorderStyle(); | |
| // Setting the border style, width and color | |
| bstyle.BorderStyle = BorderStyle.Double; | |
| bstyle.BorderWidth = new Unit(3, UnitType.Pixel); | |
| bstyle.BorderColor = Color.Blue; | |
| // Applying the instance of WebBorderStyle on a specified range of cells | |
| sheet.Cells.SetBorders(1, 1, 5, 4, SetBorderPosition.Cross, bstyle); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Merging cells starting from the cell with 3rd row and 3rd column. | |
| // 2 rows and 2 columns will be merged from the starting cell | |
| sheet.Cells.Merge(2, 2, 2, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Unmerging cells starting from the cell with 3rd row and 3rd column. | |
| // 2 rows and 2 columns will be unmerged from the starting cell | |
| sheet.Cells.UnMerge(2, 2, 2, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "B5" cell of the worksheet | |
| GridCell cell = sheet.Cells["B5"]; | |
| // Putting a numeric value as string in "B5" cell that will be converted to a suitable data type automatically | |
| cell.PutValue("19.4", true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "B3" cell of the worksheet | |
| GridCell cell = sheet.Cells["B3"]; | |
| // Putting a value in "B3" cell | |
| cell.PutValue(30); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet of the Grid that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "B1" cell of the worksheet | |
| GridCell cell = sheet.Cells["B1"]; | |
| // Accessing the string value of "B1" cell | |
| Label1.Text = cell.StringValue; | |
| // Modifying the string value of "B1" cell | |
| cell.PutValue("Hello Aspose.Grid"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Setting all cells of the worksheet to Editable | |
| sheet.SetAllCellsEditable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Setting all cells of the worksheet to Readonly | |
| sheet.SetAllCellsReadonly(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Setting all cells of the worksheet to Readonly first | |
| sheet.SetAllCellsReadonly(); | |
| // Finally, Setting selected cells of the worksheet to Editable | |
| sheet.SetEditableRange(3, 2, 4, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Setting all cells of the worksheet to Editable first | |
| sheet.SetAllCellsEditable(); | |
| // Finally, Setting selected cells of the worksheet to Readonly | |
| sheet.SetReadonlyRange(3, 2, 4, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access active worksheet | |
| var sheet = GridWeb1.WorkSheets[this.GridWeb1.ActiveSheetIndex]; | |
| // Enable GridWeb's auto-filter. | |
| sheet.AddAutoFilter(0, 0, sheet.Cells.MaxDataColumn); | |
| sheet.RefreshFilter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Access active worksheet | |
| var sheet = GridWeb1.WorkSheets[this.GridWeb1.ActiveSheetIndex]; | |
| // Enable GridWeb's custom-filter. | |
| sheet.AddCustomFilter(1, "CELL0=\"1\""); | |
| sheet.RefreshFilter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| private HttpPostedFileBase postedFile; | |
| [HttpPost] | |
| public ActionResult Index(HttpPostedFileBase file, string mode) | |
| { | |
| this.postedFile = file; | |
| Thread newThread = new Thread(Calculate, 1048576); | |
| newThread.Start(); | |
| newThread.Join(); | |
| return View(); | |
| } | |
| private void Calculate() | |
| { | |
| if (postedFile != null && postedFile.ContentLength > 0) | |
| { | |
| var wbkMain = new Workbook(postedFile.InputStream); | |
| wbkMain.CalculateFormula(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| private class CustomEngineSimple : GridAbstractCalculationEngine | |
| { | |
| public override void Calculate(GridCalculationData data) | |
| { | |
| if (!"MYTESTFUNC".Equals(data.FunctionName.ToUpper())) | |
| { | |
| return; | |
| } | |
| data.CalculatedValue = (decimal)(2.0 * (double)data.GetParamValue(0)); | |
| } | |
| } | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| // If first visit this page clear GridWeb1 and load data | |
| if (!IsPostBack && !GridWeb1.IsPostBack) | |
| { | |
| CustomEngineSimple ce = new CustomEngineSimple(); | |
| GridWeb1.CustomCalculationEngine = ce; | |
| GridWorksheet sheet = GridWeb1.ActiveSheet; | |
| GridCell cell = sheet.Cells["A1"]; | |
| cell.Formula = "=MYTESTFUNC(3.0)"; | |
| cell = sheet.Cells["A2"]; | |
| cell.PutValue("hello"); | |
| cell = sheet.Cells["B1"]; | |
| cell.PutValue(1); | |
| cell = sheet.Cells["B2"]; | |
| cell.PutValue(2); | |
| cell = sheet.Cells["B3"]; | |
| cell.PutValue(3); | |
| cell = sheet.Cells["A3"]; | |
| cell.Formula = "=SUM(B1:B3)"; | |
| GridWeb1.CalculateFormula(); | |
| sheet.ActiveCell = "A4"; | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting the PresetStyle of the control to Custom | |
| GridWeb1.PresetStyle = PresetStyle.Custom; | |
| // Setting the path of style file to load style information from this file to the control | |
| GridWeb1.CustomStyleFileName = (this.Master as Site).GetDataDir() + "\\GridWebBasics\\CustomStyle1.xml"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting header bar properties, BackColor, ForeColor, Font & BorderWidth | |
| GridWeb1.HeaderBarStyle.BackColor = System.Drawing.Color.Brown; | |
| GridWeb1.HeaderBarStyle.ForeColor = System.Drawing.Color.Yellow; | |
| GridWeb1.HeaderBarStyle.Font.Bold = true; | |
| GridWeb1.HeaderBarStyle.Font.Name = "Century Gothic"; | |
| GridWeb1.HeaderBarStyle.BorderWidth = new Unit(2, UnitType.Point); | |
| // Setting Tab properties, BackColor, ForeColor | |
| GridWeb1.TabStyle.BackColor = System.Drawing.Color.Yellow; | |
| GridWeb1.TabStyle.ForeColor = System.Drawing.Color.Blue; | |
| // Setting Active Tab properties, BackColor, ForeColor | |
| GridWeb1.ActiveTabStyle.BackColor = System.Drawing.Color.Blue; | |
| GridWeb1.ActiveTabStyle.ForeColor = System.Drawing.Color.Yellow; | |
| // Saving style information to an XML file | |
| GridWeb1.SaveCustomStyleFile((this.Master as Site).GetDataDir() + "\\GridWebBasics\\CustomPresetStyle_out.xml"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Enabling the Edit Mode of GridWeb | |
| GridWeb1.EditMode = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Enabling the View Mode of GridWeb | |
| GridWeb1.EditMode = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting header bar properties, BackColor, ForeColor, Font & BorderWidth | |
| GridWeb1.HeaderBarStyle.BackColor = System.Drawing.Color.Brown; | |
| GridWeb1.HeaderBarStyle.ForeColor = System.Drawing.Color.Yellow; | |
| GridWeb1.HeaderBarStyle.Font.Bold = true; | |
| GridWeb1.HeaderBarStyle.Font.Name = "Century Gothic"; | |
| GridWeb1.HeaderBarStyle.BorderWidth = new Unit(2, UnitType.Point); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Applying Colorful1 style on the GridWeb control | |
| GridWeb1.PresetStyle =PresetStyle.Colorful1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Enabling the Sessionless Mode of GridWeb | |
| GridWeb1.SessionMode = SessionMode.ViewState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Enabling the Session Mode of GridWeb | |
| GridWeb1.SessionMode = SessionMode.Session; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting Tab properties, BackColor, ForeColor | |
| GridWeb1.TabStyle.BackColor = System.Drawing.Color.Yellow; | |
| GridWeb1.TabStyle.ForeColor = System.Drawing.Color.Blue; | |
| // Setting active tab properties, BackColor, ForeColor | |
| GridWeb1.ActiveTabStyle.BackColor = System.Drawing.Color.Blue; | |
| GridWeb1.ActiveTabStyle.ForeColor = System.Drawing.Color.Yellow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Making the Edit Box (toolbar) visible for the GridWeb control | |
| GridWeb1.ShowCellEditBox = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| function GetVersion() | |
| { | |
| alert(acw_version); | |
| console.log(acw_version); | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Find version of GridWeb and display in label. | |
| string version = Aspose.Cells.GridWeb.GridWeb.GetVersion(); | |
| Label1.Text = "GridWeb Version: " + version; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Creating Event Handler for CustomCommand event | |
| protected void GridWeb1_CustomCommand(object sender, string command) | |
| { | |
| // Identifying a specific button by checking its command | |
| if (command.Equals("MyButton")) | |
| { | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Putting value to "A1" cell | |
| sheet.Cells["A1"].PutValue("My Custom Command Button is Clicked."); | |
| // Set first column width to make the text visible | |
| sheet.Cells.SetColumnWidth(0, 30); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Event Handler for CellDoubleClick event | |
| protected void GridWeb1_CellDoubleClick(object sender, Aspose.Cells.GridWeb.CellEventArgs e) | |
| { | |
| // Displaying the name of the cell (that is double clicked) in GridWeb's Message Box | |
| string msg = "You just clicked <"; | |
| msg += "Row: " + (e.Cell.Row + 1) + " Column: " + (e.Cell.Column + 1) + " Cell Name: " + e.Cell.Name + ">"; | |
| GridWeb1.Message = msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Event Handler for ColumnDoubleClick event | |
| protected void GridWeb1_ColumnDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e) | |
| { | |
| // Displaying the number of the column (whose header is double clicked) in GridWeb's Message Box | |
| string msg = "You just clicked <"; | |
| msg += "Column header: " + (e.Num + 1) + ">"; | |
| GridWeb1.Message = msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Enabling Double Click events | |
| GridWeb1.EnableDoubleClickEvent = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Event Handler for RowDoubleClick event | |
| protected void GridWeb1_RowDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e) | |
| { | |
| // Displaying the number of the row (whose header is double clicked) in GridWeb's Message Box | |
| string msg = "You just clicked <"; | |
| msg += "Row header: " + (e.Num + 1) + ">"; | |
| GridWeb1.Message = msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Gets the web application's path. | |
| string path = (this.Master as Site).GetDataDir(); | |
| string fileName = path + "\\GridWebBasics\\SampleData.xls"; | |
| // Imports from an excel file. | |
| GridWeb1.ImportExcelFile(fileName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Generates a temporary file name. | |
| string filename = Session.SessionID + "_out.xls"; | |
| string path = (this.Master as Site).GetDataDir() + "\\GridWebBasics\\"; | |
| // Saves to the file. | |
| this.GridWeb1.SaveToExcelFile(path + filename); | |
| // Sents the file to browser. | |
| Response.ContentType = "application/vnd.ms-excel"; | |
| Response.AddHeader("content-disposition", "attachment; filename=" + filename); | |
| Response.WriteFile(path + filename); | |
| Response.End(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Gets the web application's path. | |
| string path = (this.Master as Site).GetDataDir(); | |
| string fileName = path + "\\GridWebBasics\\SampleData.xls"; | |
| // Opening an Excel file as a stream | |
| FileStream fs = File.OpenRead(fileName); | |
| // Loading the Excel file contents into the control from a stream | |
| GridWeb1.ImportExcelFile(fs); | |
| // Closing stream | |
| fs.Close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Generates a temporary file name. | |
| string filename = Session.SessionID + "_out.xls"; | |
| string path = (this.Master as Site).GetDataDir() + "\\GridWebBasics\\"; | |
| FileStream fs = File.Create(path + filename); | |
| // Saving Grid content of the control to a stream | |
| GridWeb1.SaveToExcelFile(fs); | |
| // Closing stream | |
| fs.Close(); | |
| // Sents the file to browser. | |
| Response.ContentType = "application/vnd.ms-excel"; | |
| Response.AddHeader("content-disposition", "attachment; filename=" + filename); | |
| Response.WriteFile(path + filename); | |
| Response.End(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick="Print();return false;" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <script> | |
| function Print(grid) { | |
| // Get Id of GridWeb | |
| var grid = document.getElementById('<%= GridWeb1.ClientID %>'); | |
| // Call print | |
| grid.print(); | |
| } | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting the height of GridWeb control | |
| GridWeb1.Height = new Unit(200, UnitType.Point); | |
| // Setting the width of GridWeb control | |
| GridWeb1.Width = new Unit(520, UnitType.Point); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Setting the height of header bar | |
| GridWeb1.HeaderBarHeight = new Unit(35, UnitType.Point); | |
| // Setting the width of header bar | |
| GridWeb1.HeaderBarWidth = new Unit(50, UnitType.Point); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <form id="form1" runat="server"> | |
| <div> | |
| <acw:GridWeb ID="GridWeb1" runat="server" XhtmlMode="True" Height="350px" Width="700px"> | |
| </acw:GridWeb> | |
| </div> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Access the first worksheet | |
| GridWorksheet gridSheet = GridWeb1.WorkSheets[0]; | |
| //Input data into the cells of the first worksheet. | |
| gridSheet.Cells["A1"].PutValue("Product1"); | |
| gridSheet.Cells["A2"].PutValue("Product2"); | |
| gridSheet.Cells["A3"].PutValue("Product3"); | |
| gridSheet.Cells["A4"].PutValue("Product4"); | |
| gridSheet.Cells["B1"].PutValue(100); | |
| gridSheet.Cells["B2"].PutValue(200); | |
| gridSheet.Cells["B3"].PutValue(300); | |
| gridSheet.Cells["B4"].PutValue(400); | |
| //Set the caption of the first two columns. | |
| gridSheet.SetColumnCaption(0, "Product Name"); | |
| gridSheet.SetColumnCaption(1, "Price"); | |
| //Set the column width of the first column. | |
| gridSheet.Cells.SetColumnWidth(0, 20); | |
| //Set the second column header's tip. | |
| gridSheet.SetColumnHeaderToolTip(1, "Unit Price of Products"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // A client side JavaScript function that will be executed before submitting data to server | |
| function ConfirmFunction(arg, cancelEdit) { | |
| // Showing a confirm dialog with some information where "this" refers to GridWeb | |
| return confirm("The control is " + this.id + "\nThe command is \"" + arg + "\".\nDo you want to continue?"); | |
| } | |
| // A client side JavaScript function that will be executed whenever a validation error will occur | |
| function ValidationErrorFunction() { | |
| // Showing an alert message where "this" refers to GridWeb | |
| alert(this.id + ": Please correct your input error."); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Assigning the name of JavaScript function to OnSubmitClientFunction property of GridWeb | |
| GridWeb1.OnSubmitClientFunction = "ConfirmFunction"; | |
| // Assigning the name of JavaScript function to OnValidationErrorClientFunction property of GridWeb | |
| GridWeb1.OnValidationErrorClientFunction = "ValidationErrorFunction"; | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing "B1" cell and add some text | |
| GridCell cell = sheet.Cells[0, 1]; | |
| cell.PutValue("Date (yyyy-mm-dd):"); | |
| // Accessing "C1" cell and add to it custom expression validation to accept dates in yyyy-mm-dd format | |
| cell = sheet.Cells[0, 2]; | |
| var validation = cell.CreateValidation(GridValidationType.CustomExpression, true); | |
| validation.RegEx = @"\d{4}-\d{2}-\d{2}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <head id="Head1" runat="server"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/> | |
| </head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| FileStream fs1 = new FileStream(path + "\\KnowledgeBase\\SampleData.xlsx", FileMode.Open, FileAccess.Read); | |
| byte[] data1 = new byte[fs1.Length]; | |
| fs1.Read(data1, 0, data1.Length); | |
| this.Response.ContentType = "application/xls"; | |
| Response.AddHeader("content-disposition", "inline; filename=book1.xls"); | |
| Response.BinaryWrite(data1); | |
| Response.End(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Saves file to memory | |
| MemoryStream stream = new MemoryStream(); | |
| excel.Save(stream, SaveFormat.Excel97To2003); | |
| Response.ContentType = "application/vnd.ms-excel"; | |
| // This is same as OpenInExcel option | |
| Response.AddHeader("content-disposition", "attachment; filename=book1.xls"); | |
| // This is same as OpenInBrowser option | |
| // response.AddHeader("content-disposition", "inline; filename=book1.xls"); | |
| Response.BinaryWrite(stream.ToArray()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| Response.AddHeader("content-disposition", "inline; filename=book1.xls"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Get column index entered by user | |
| int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
| // Add column at specified index | |
| sheet.Cells.InsertColumn(columnIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Get row index entered by user | |
| int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
| // Add row at specified index | |
| sheet.Cells.InsertRow(rowIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get the instance of active GridWorksheet | |
| var activeSheet = GridWeb1.ActiveSheet; | |
| // Copy first column to next column | |
| activeSheet.Cells.CopyColumn(activeSheet.Cells, 0, 1); | |
| Label1.Text = "Column 1 copied to column 2 in worksheet " + activeSheet.Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get the instance of active GridWorksheet | |
| var activeSheet = GridWeb1.ActiveSheet; | |
| // Copy first 3 column to 7th column | |
| activeSheet.Cells.CopyColumns(activeSheet.Cells, 0, 6, 3); | |
| Label1.Text = "Columns 1 to 3 copied to columns 7 to 9 in worksheet " + activeSheet.Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get the instance of active GridWorksheet | |
| var activeSheet = GridWeb1.ActiveSheet; | |
| // Copy first 3 rows to 7th row | |
| activeSheet.Cells.CopyRows(activeSheet.Cells, 0, 6, 3); | |
| Label1.Text = "Rows 1 to 3 copied to rows 7 to 9 in worksheet " + activeSheet.Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get the instance of active GridWorksheet | |
| var activeSheet = GridWeb1.ActiveSheet; | |
| // Copy first row to next row | |
| activeSheet.Cells.CopyRow(activeSheet.Cells, 0, 1); | |
| Label1.Text = "Row 1 copied to row 2 in worksheet " + activeSheet.Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet that is currently active | |
| GridWorksheet workSheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Creates custom column header caption. | |
| workSheet.SetColumnCaption(0, "Product"); | |
| workSheet.SetColumnCaption(1, "Category"); | |
| workSheet.SetColumnCaption(2, "Price"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the worksheet that is currently active | |
| GridWorksheet workSheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Create custom row header caption. | |
| workSheet.SetRowCaption(1, "Row1"); | |
| workSheet.SetRowCaption(2, "Row2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Get column index entered by user | |
| int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
| // Delete column at specified index | |
| sheet.Cells.DeleteColumn(columnIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Get row index entered by user | |
| int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
| // Delete row at specified index | |
| sheet.Cells.DeleteRow(rowIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get user inputs for row, column, number of rows and number of columns | |
| int row = Convert.ToInt16(txtRow.Text.Trim()); | |
| int column = Convert.ToInt16(txtColumn.Text.Trim()); | |
| int noOfRows = Convert.ToInt16(txtNoOfRows.Text.Trim()); | |
| int noOfColumns = Convert.ToInt16(txtNoOfColumns.Text.Trim()); | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Freeze desired rows and columns | |
| sheet.FreezePanes(row, column, noOfRows, noOfColumns); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Unfreezing rows and columns | |
| sheet.UnFreezePanes(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <acw:GridWeb ID="GridWeb1" runat="server" | |
| OnBeforeColumnFilter="GridWeb1_BeforeColumnFilter" | |
| OnAfterColumnFilter="GridWeb1_AfterColumnFilter"> | |
| </acw:GridWeb> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| protected void GridWeb1_AfterColumnFilter(object sender, RowColumnEventArgs e) | |
| { | |
| string hidden = ""; | |
| int headrow = 0; | |
| int maxrow = GridWeb1.WorkSheets[0].Cells.MaxRow; | |
| int count = 0; | |
| // Iterate all worksheet rows to find out filtered rows | |
| for (int i = headrow + 1; i <= maxrow; i++) | |
| { | |
| if (GridWeb1.WorkSheets[0].Cells.Rows[i].Hidden) | |
| { | |
| hidden += "-" + (i + 1); | |
| } | |
| else | |
| { | |
| count++; | |
| } | |
| } | |
| // Display hidden rows and visible rows count | |
| string msg = "[Hidden Rows]: " + hidden + " [Visible Rows]: " + count; | |
| Label1.Text = msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| protected void GridWeb1_BeforeColumnFilter(object sender, RowColumnEventArgs e) | |
| { | |
| // Display the column index and filter applied | |
| string msg = "[Column Index]: " + (e.Num) + ", [Filter Value]: " + e.Argument; | |
| Label1.Text = msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the first worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Set the 1st cell (A1) read only | |
| sheet.SetIsReadonly(sheet.Cells["A1"], true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get column index entered by user | |
| int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
| // Get column width entered by user | |
| int columnWidth = Convert.ToInt16(txtColumnWidth.Text.Trim()); | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
| // Resize column at specified index to specified width | |
| cells.SetColumnWidth(columnIndex, columnWidth); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Get row index entered by user | |
| int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
| // Get row height entered by user | |
| int rowHeight = Convert.ToInt16(txtRowHeight.Text.Trim()); | |
| // Accessing the cells collection of the worksheet that is currently active | |
| GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
| // Resize row at specified index to specified height | |
| cells.SetRowHeight(rowIndex, rowHeight); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //---------------------------------------------------------------------- | |
| //------MakingGridWebResizableUsingResizablejQueryUiFeature.aspx-------- | |
| //---------------------------------------------------------------------- | |
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MakingGridWebResizableUsingResizablejQueryUiFeature.aspx.cs" Inherits="Aspose.Cells.GridWeb.Examples.CSharp.WorkingWithGridWebClientSideScript.MakingGridWebResizableUsingResizablejQueryUiFeature" %> | |
| <%@ Register TagPrefix="acw" Namespace="Aspose.Cells.GridWeb" Assembly="Aspose.Cells.GridWeb" %> | |
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head runat="server"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js" type="text/javascript"></script> | |
| <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" /> | |
| <script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> | |
| <script type="text/javascript"> | |
| $(function () { | |
| $("#resizable").resizable( | |
| { | |
| resize: function () { | |
| $("#GridWeb1").height($("#resizable").height()); | |
| $("#GridWeb1").width($("#resizable").width()); | |
| $("#GridWeb1")[0].resize(); | |
| } | |
| } | |
| ); | |
| }); | |
| </script> | |
| <title>Making GridWeb resizable using resizable jquery ui feature</title> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div id="resizable" class="ui-widget-content"> | |
| <acw:GridWeb ID="GridWeb1" runat="server" XhtmlMode="True" Height="400px" Width="100%"> | |
| </acw:GridWeb> | |
| </div> | |
| </form> | |
| </body> | |
| </html> | |
| //---------------------------------------------------------------------- | |
| //------MakingGridWebResizableUsingResizablejQueryUiFeature.aspx.cs----- | |
| //---------------------------------------------------------------------- | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| namespace Aspose.Cells.GridWeb.Examples.CSharp.WorkingWithGridWebClientSideScript | |
| { | |
| public partial class MakingGridWebResizableUsingResizablejQueryUiFeature : System.Web.UI.Page | |
| { | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (Page.IsPostBack == false && this.GridWeb1.IsPostBack == false) | |
| { | |
| string filePath = Server.MapPath("~/01_SourceDirectory/sampleResizableGridWeb.xlsx"); | |
| GridWeb1.ImportExcelFile(filePath); | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //---------------------------------------------------------------------- | |
| //------ResizeGridWebUsingResizeMethod.aspx----------------------------- | |
| //---------------------------------------------------------------------- | |
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResizeGridWebUsingResizeMethod.aspx.cs" Inherits="Aspose.Cells.GridWeb.Examples.CSharp.WorkingWithGridWebClientSideScript.ResizeGridWebUsingResizeMethod" %> | |
| <%@ Register TagPrefix="acw" Namespace="Aspose.Cells.GridWeb" Assembly="Aspose.Cells.GridWeb" %> | |
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head runat="server"> | |
| <style type="text/css"> | |
| .fullheight { | |
| display: inline-block; | |
| min-height: 80%; | |
| height: 90%; | |
| padding: 0; | |
| position: relative; | |
| margin-right: -0.3em; | |
| vertical-align: top; | |
| } | |
| html, body, form { | |
| background: #b6b7bc; | |
| font-size: .80em; | |
| font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; | |
| margin: 0px; | |
| padding: 0px; | |
| color: #000000; | |
| min-height: 99%; | |
| height: 100%; | |
| overflow: visible; | |
| } | |
| </style> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js" type="text/javascript"></script> | |
| <script type="text/javascript"> | |
| function doResizing() { | |
| //alert("I'm done resizing for the moment"); | |
| $("#GridWeb1")[0].resize(); | |
| }; | |
| var resizeTimer; | |
| $(window).resize(function () { | |
| clearTimeout(resizeTimer); | |
| resizeTimer = setTimeout(doResizing, 100); | |
| }); | |
| </script> | |
| <title>Using GridWeb’s resize method</title> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div style="width: 100%; height: 100%; overflow: visible;"> | |
| <span id="gridwebpanel" class="fullheight"> | |
| <acw:GridWeb ID="GridWeb1" runat="server" Width="100%" Height="100%" ShowLoading="true" XhtmlMode="true" | |
| PresetStyle="Standard" EnableAJAX="true"> | |
| </acw:GridWeb> | |
| </span> | |
| </div> | |
| </form> | |
| </body> | |
| </html> | |
| //---------------------------------------------------------------------- | |
| //------ResizeGridWebUsingResizeMethod.aspx.cs-------------------------- | |
| //---------------------------------------------------------------------- | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| namespace Aspose.Cells.GridWeb.Examples.CSharp.WorkingWithGridWebClientSideScript | |
| { | |
| public partial class ResizeGridWebUsingResizeMethod : System.Web.UI.Page | |
| { | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (Page.IsPostBack == false && this.GridWeb1.IsPostBack == false) | |
| { | |
| string filePath = Server.MapPath("~/01_SourceDirectory/sampleResizableGridWeb.xlsx"); | |
| GridWeb1.ImportExcelFile(filePath); | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Inserting dummy data | |
| GridWeb1.WorkSheets[0].Cells["B1"].PutValue(100); | |
| GridWeb1.WorkSheets[0].Cells["B2"].PutValue(200); | |
| GridWeb1.WorkSheets[0].Cells["B3"].PutValue(300); | |
| GridWeb1.WorkSheets[0].Cells["B4"].PutValue(400); | |
| // Add a new named range "MyRange" with based area B1:B4 | |
| GridWeb1.WorkSheets.Names.Add("MyRange", "Sheet1!B1:B4"); | |
| // Apply a formula to a cell that refers to a named range "MyRange" | |
| GridWeb1.WorkSheets[0].Cells["A1"].Formula = "=SUM(MyRange)"; | |
| // Apply a formula to A2 cell | |
| GridWeb1.WorkSheets[0].Cells["A2"].Formula = "=Average(MyRange)"; | |
| // Calculate the results of the formulas | |
| GridWeb1.WorkSheets.CalculateFormula(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing a worksheet using its index | |
| GridWorksheet sheet = GridWeb1.WorkSheets[0]; | |
| Label1.Text = "Sheet at index 0 is : " + sheet.Name + "<br/>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing a worksheet using its name | |
| GridWorksheet sheet1 = GridWeb1.WorkSheets["Catalog"]; | |
| Label1.Text += "Index of sheet Catalog is : " + sheet1.Index + "<br/>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Adding hyperlink to the worksheet | |
| int linkIndex = sheet.Hyperlinks.Add("B8", ""); | |
| GridHyperlink link1 = sheet.Hyperlinks[linkIndex]; | |
| // Setting the cell command, tool tip and image URL for the hyperlink | |
| link1.Command = "Click"; | |
| link1.ScreenTip = "Click Here"; | |
| link1.ImageURL = "../Images/button.jpg"; | |
| // Resize the row to display image nicely | |
| sheet.Cells.SetRowHeight(7, 30); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Adding hyperlink to the worksheet | |
| int linkIndex = sheet.Hyperlinks.Add("B5", "http://www.aspose.com"); | |
| GridHyperlink link1 = sheet.Hyperlinks[linkIndex]; | |
| link1.Target = "_blank"; | |
| // Setting Image URL and tool tip of hyperlink | |
| link1.ImageURL = "../Images/Aspose.Banner.gif"; | |
| link1.ScreenTip = "Open Aspose Web Site in new window"; | |
| // Adding hyperlink to the worksheet | |
| linkIndex = sheet.Hyperlinks.Add("B6", "http://www.aspose.com/docs/display/cellsnet/Aspose.Cells.GridWeb"); | |
| GridHyperlink link2 = sheet.Hyperlinks[linkIndex]; | |
| link2.Target = "_blank"; | |
| // Setting URL, tool tip and alt text of hyperlink | |
| link2.ImageURL = "../Images/Aspose.Grid.gif"; | |
| link2.ScreenTip = "Open Aspose.Grid Docs in new window"; | |
| link2.AltText = "Open Aspose.Grid Docs in new window"; | |
| // Resize the rows to display image nicely | |
| sheet.Cells.SetRowHeight(4, 40); | |
| sheet.Cells.SetRowHeight(5, 40); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Adds a text hyperlink that goes to Aspose site and opens in new window | |
| int linkIndex = sheet.Hyperlinks.Add("B1", "http://www.aspose.com"); | |
| GridHyperlink link1 = sheet.Hyperlinks[linkIndex]; | |
| link1.Target = "_blank"; | |
| // Setting text and tool tip of the hyperlink | |
| link1.TextToDisplay = "Aspose"; | |
| link1.ScreenTip = "Open Aspose Web Site in new window"; | |
| // Adding hyperlink to the worksheet to open in parent window | |
| linkIndex = sheet.Hyperlinks.Add("B2", "http://www.aspose.com/docs/display/cellsnet/Aspose.Cells.GridWeb"); | |
| GridHyperlink link2 = sheet.Hyperlinks[linkIndex]; | |
| link2.Target = "_parent"; | |
| // Setting text and tool tip of the hyperlink | |
| link2.TextToDisplay = "Aspose.Grid Docs"; | |
| link2.ScreenTip = "Open Aspose.Grid Docs in parent window"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Event Handler for CellCommand event | |
| protected void GridWeb1_CellCommand(object sender, Aspose.Cells.GridWeb.CellEventArgs e) | |
| { | |
| // Checking the CellCommand of the hyperlink | |
| if (e.Argument.Equals("Click")) | |
| { | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Adding value to "C8" cell | |
| sheet.Cells["C8"].PutValue("Cell Command Hyperlink Clicked"); | |
| // Resize the column to display message nicely | |
| sheet.Cells.SetColumnWidth(2, 250); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Adding a worksheet to GridWeb with a specified name | |
| if (GridWeb1.WorkSheets["Teachers"] == null) | |
| { | |
| GridWorksheet sheet1 = GridWeb1.WorkSheets.Add("Teachers"); | |
| Label1.Text += sheet1.Name + " worksheet is added at index " + sheet1.Index + ". <br/>"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Adding a worksheet to GridWeb without specifying name | |
| int sheetIndex = GridWeb1.WorkSheets.Add(); | |
| GridWorksheet sheet = GridWeb1.WorkSheets[sheetIndex]; | |
| Label1.Text = sheet.Name + " worksheet is added at index " + sheetIndex + ". <br/>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Adding the copy of a worksheet to GridWeb by specifying its sheet index | |
| int sheetIndex = GridWeb1.WorkSheets.AddCopy(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Adding the copy of a worksheet to GridWeb by specifying its sheet name | |
| int sheetIndex1 = GridWeb1.WorkSheets.AddCopy("Students"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Creating a new DataTable object | |
| DataTable dataTable = new DataTable(); | |
| // Adding specific columns to the DataTable object | |
| dataTable.Columns.Add("Name", System.Type.GetType("System.String")); | |
| dataTable.Columns.Add("Gender", System.Type.GetType("System.String")); | |
| dataTable.Columns.Add("Age", System.Type.GetType("System.Int32")); | |
| dataTable.Columns.Add("Class", System.Type.GetType("System.String")); | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Getting the total number of rows and columns inside the worksheet | |
| int totalColumns = sheet.Cells.MaxColumn + 1; | |
| int totalRows = sheet.Cells.MaxRow + 1; | |
| // Exporting the data of the active worksheet to a specific DataTable object | |
| dataTable = sheet.Cells.Export(0, 0, totalRows, totalColumns, true, true); | |
| // Display exported data table in GridView | |
| GridView1.DataSource = dataTable; | |
| GridView1.DataBind(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet1 = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Getting the total number of rows and columns inside the worksheet | |
| int totalColumns1 = sheet.Cells.MaxColumn + 1; | |
| int totalRows1 = sheet.Cells.MaxRow + 1; | |
| // Exporting the data of the active worksheet to a new DataTable object | |
| DataTable dt = sheet.Cells.Export(0, 0, totalRows1, totalColumns1, true, true); | |
| // Display exported data table in GridView | |
| GridView2.DataSource = dataTable; | |
| GridView2.DataBind(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Connect database | |
| System.Data.OleDb.OleDbConnection oleDbConnection1 = new OleDbConnection(); | |
| System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter(); | |
| System.Data.OleDb.OleDbCommand oleDbSelectCommand1 = new OleDbCommand(); | |
| string path = (this.Master as Site).GetDataDir(); | |
| oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Worksheets\\Database\\Northwind.mdb"; | |
| oleDbSelectCommand1.Connection = oleDbConnection1; | |
| oleDbDataAdapter1.SelectCommand = oleDbSelectCommand1; | |
| DataTable dataTable1 = new DataTable(); | |
| dataTable1.Reset(); | |
| // Queries database. | |
| try | |
| { | |
| oleDbSelectCommand1.CommandText = "SELECT CategoryID, CategoryName, Description FROM Categories"; | |
| oleDbDataAdapter1.Fill(dataTable1); | |
| } | |
| catch | |
| { | |
| } | |
| finally | |
| { | |
| oleDbConnection1.Close(); | |
| } | |
| // Imports data from dataview object. | |
| dataTable1.TableName = "Categories"; | |
| GridWeb1.WorkSheets.Clear(); | |
| GridWeb1.WorkSheets.ImportDataView(dataTable1.DefaultView, null, null); | |
| // Imports data from dataview object with sheet name and position specified. | |
| GridWeb1.WorkSheets.ImportDataView(dataTable1.DefaultView, null, null, "SpecifiedName&Position", 2, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing a specific cell that contains comment | |
| GridCell cell = sheet.Cells["A1"]; | |
| // Accessing the comment from the specific cell | |
| GridComment comment = sheet.Comments[cell.Name]; | |
| if (comment != null) | |
| { | |
| // Modifying the comment note | |
| comment.Note = "I have modified the comment note."; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active and add a dummy value to cell A1 | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| sheet.Cells["A1"].PutValue("This cell has a comment added, hover to view."); | |
| // Resize first column | |
| sheet.Cells.SetColumnWidth(0, 140); | |
| // Adding comment to "A1" cell of the worksheet | |
| GridComment comment = sheet.Comments[sheet.Comments.Add("A1")]; | |
| // Setting the comment note | |
| comment.Note = "These are my comments for the cell"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing a specific cell that contains comment | |
| GridCell cell = sheet.Cells["A1"]; | |
| // Removing comment from the specific cell | |
| sheet.Comments.RemoveAt(cell.Name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Accessing a specific cell that contains hyperlink | |
| GridCell cell = sheet.Cells["B1"]; | |
| // Accessing the hyperlink from the specific cell | |
| GridHyperlink link = sheet.Hyperlinks.GetHyperlink(cell); | |
| if (link != null) | |
| { | |
| // Modifying the text and URL of hyperlink | |
| link.TextToDisplay = "Aspose.Blogs"; | |
| link.Address = "http://www.aspose.com/Community/Blogs"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Accessing the reference of the worksheet that is currently active | |
| GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
| // Removing hyperlink from the specific cell | |
| sheet.Hyperlinks.Remove(new Data.GridCellArea() {StartRow = 0, EndRow = 0, StartColumn = 1, EndColumn = 1}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| if (GridWeb1.WorkSheets.Count > 2) | |
| { | |
| // Removing a worksheet using its index | |
| GridWeb1.WorkSheets.RemoveAt(1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Removing a worksheet using its name | |
| if (GridWeb1.WorkSheets["Teachers"] != null) | |
| { | |
| GridWeb1.WorkSheets.RemoveAt("Teachers"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Renaming a worksheet | |
| GridWeb1.WorkSheets[0].Name = "Students"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Sorts Row 1 from left to right in ascending order | |
| // Cells.Sort(int startRow, int startColumn, int rows, int columns, int index, bool isAsending, bool isCaseSensitive, bool islefttoright); | |
| GridWeb1.WorkSheets[1].Cells.Sort(0, 1, 4, 7, 0, true, true, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Sorts Column 1 from top to bottom in descending order | |
| // Cells.Sort(int startRow, int startColumn, int rows, int columns, int index, bool isAsending, bool isCaseSensitive, bool islefttoright); | |
| GridWeb1.WorkSheets[0].Cells.Sort(1, 0, 20, 4, 0, false, true, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GridWorkbookSettings gws = new GridWorkbookSettings(); | |
| //do not re-calculate all formulas on opening the file. | |
| gws.ReCalculateOnOpen = false; | |
| GridWeb1.Settings = gws; | |
| GridWeb1.ImportExcelFile(@"c:\test.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Change the numeric decimal separator to "^" char. | |
| GridWeb1.WorkSheets.NumberDecimalSeparator = '^'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment