Last active
July 20, 2020 12:28
-
-
Save aspose-com-gists/450189dd05e175bb3c7765dbe7c33651 to your computer and use it in GitHub Desktop.
This Gist contains code snippets for examples of Aspose.Cells.GridDesktop.
This file contains 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 snippets for examples of Aspose.Cells.GridDesktop. |
This file contains 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 | |
//Path of the sample Excel file containing Pivot Table | |
string filePath = Utils.Get_SourceDirectory() + "sampleRenderPivotTableInGridDesktop.xlsx"; | |
//Import sample Excel file containing Pivot Table | |
this.gridDesktop1.ImportExcelFile(filePath); |
This file contains 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 version number of GridDesktop | |
string version = Aspose.Cells.GridDesktop.GridDesktop.GetVersion(); | |
//Show the version number in message box | |
MessageBox.Show("GridDesktop Version: " + version, "GridDesktop Version"); |
This file contains 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 | |
/* | |
* Indicates whether to copy/paste based on clipboard, so that it can copy/paste with MS-EXCEL. | |
* It will only copy/paste cell value and will not copy any other setting of the cell like format, border style and so on. | |
* The default value is false. | |
*/ | |
gridDesktop1.EnableClipboardCopyPaste = true; |
This file contains 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 namespace to the top of code | |
using System.Data.OleDb; |
This file contains 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 new row to the worksheet | |
gridDesktop1.GetActiveWorksheet().AddRow(); |
This file contains 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 | |
// Iterating through each column of the worksheet | |
for (int i = 0; i < sheet.ColumnsCount; i++) | |
{ | |
// Getting the style object of each column | |
Style style = sheet.Columns[i].GetStyle(); | |
// Setting the color of each column to Yellow | |
style.Color = Color.Yellow; | |
// Setting the Horizontal Alignment of each column to Centered | |
style.HAlignment = HorizontalAlignmentType.Centred; | |
// Setting the style of column to the updated one | |
sheet.Columns[i].SetStyle(style); | |
} |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Binding the Worksheet to Products table by calling its DataBind method | |
sheet.DataBind(ds.Tables["Products"], ""); |
This file contains 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 | |
// Customizing the widths of columns of the worksheet | |
sheet.Columns[0].Width = 70; | |
sheet.Columns[1].Width = 120; | |
sheet.Columns[2].Width = 80; |
This file contains 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 | |
// Declaring global variable | |
OleDbDataAdapter adapter; | |
OleDbCommandBuilder cb; | |
DataSet ds; |
This file contains 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 | |
// Getting the index of the focused row | |
int focusedRowIndex = gridDesktop1.GetActiveWorksheet().GetFocusedCell().Row; | |
// Removing the focused row fro the worksheet | |
gridDesktop1.GetActiveWorksheet().RemoveRow(focusedRowIndex); |
This file contains 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 void DataBindingFeatures_Load(object sender, EventArgs e) | |
{ | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Creating Select query to fetch data from database | |
string query = "SELECT * FROM Products ORDER BY ProductID"; | |
// Creating connection string to connect with database | |
string conStr = @"Provider=microsoft.jet.oledb.4.0;Data Source=" + dataDir + "dbDatabase.mdb"; | |
// Creating OleDbDataAdapter object that will be responsible to open/close connections with database, fetch data and fill DataSet with data | |
adapter = new OleDbDataAdapter(query, conStr); | |
// Setting MissingSchemaAction to AddWithKey for getting necesssary primary key information of the tables | |
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; | |
/* | |
* Creating OleDbCommandBuilder object to create insert/delete SQL commmands | |
* automatically that are used by OleDbDatAdapter object for updating | |
* changes to the database | |
*/ | |
cb = new OleDbCommandBuilder(adapter); | |
// Creating DataSet object | |
ds = new DataSet(); | |
// Filling DataSet with data fetched by OleDbDataAdapter object | |
adapter.Fill(ds, "Products"); | |
} |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Updating the database according to worksheet data source | |
adapter.Update((DataTable)sheet.DataSource); |
This file contains 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 | |
// Iterating through all columns of the Products table in DataSet | |
for (int i = 0; i < ds.Tables["Products"].Columns.Count; i++) | |
{ | |
// Setting the column header of each column to the column caption of Products table | |
sheet.Columns[i].Header = ds.Tables["Products"].Columns[i].Caption; | |
} |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Setting the value of "A1" cell | |
cell.SetCellValue(DateTime.Now); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Accessing & modifying the value of "A1" cell | |
cell.Value = DateTime.Now; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its row and column indices | |
GridCell cell = sheet.Cells[1, 1]; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its name | |
GridCell cell = sheet.Cells["A1"]; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell that is currently in focus | |
GridCell cell = sheet.GetFocusedCell(); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Make sure sheet has been protected | |
sheet.Protected = true; | |
// Choose a cell range | |
CellRange range = sheet.CreateRange("A1", "B1"); | |
// Set protected range area on Worksheet | |
sheet.SetProtected(range, true); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding numeric values to "B2" & "B3" cells | |
sheet.Cells["B2"].SetCellValue(3); | |
sheet.Cells["B3"].SetCellValue(4); | |
// Adding a formula to "B4" cell multiplying the values of "B2" & "B3" cells | |
sheet.Cells["B4"].SetCellValue("=B2 * B3"); | |
// Running all formulas in the Grid | |
gridDesktop1.RunAllFormulas(); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing "A1" cell in the worksheet | |
GridCell cell = sheet.Cells["A1"]; | |
// Adding a value to "A1" cell | |
cell.Value = "Hello"; | |
// Getting the Style object for the cell | |
Style style = cell.GetStyle(); | |
// Setting Style properties like border, alignment etc. | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thick); | |
style.SetBorderColor(BorderType.Right, Color.Blue); | |
style.HAlignment = HorizontalAlignmentType.Centred; | |
style.Color = Color.Yellow; | |
style.CellLocked = true; | |
style.VAlignment = VerticalAlignmentType.Top; | |
// Setting the style of the cell with the customized Style object | |
cell.SetStyle(style); |
This file contains 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 first worksheet of the Grid | |
Aspose.Cells.GridDesktop.Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Creating a standard Font object that will be applied on cells | |
System.Drawing.Font font = new System.Drawing.Font("MS Serif", 9f, FontStyle.Bold); | |
// Accessing and adding values to cells | |
Aspose.Cells.GridDesktop.GridCell cell = sheet.Cells["B2"]; | |
cell.Value = "General"; | |
cell.SetFont(font); | |
cell = sheet.Cells["C2"]; | |
cell.Value = 1000; | |
cell = sheet.Cells["D2"]; | |
cell.Value = "Text"; | |
cell = sheet.Cells["B4"]; | |
cell.Value = "Number"; | |
cell.SetFont(font); | |
//Accessing the Style object of "C4" cell and setting its number format to index No.2 | |
cell = sheet.Cells["C4"]; | |
cell.Value = 20.00; | |
Aspose.Cells.GridDesktop.Style style = cell.GetStyle(); | |
// For applying "0.00" format | |
style.NumberFormat = 2; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D4" cell and setting its number format to index No.3 | |
cell = sheet.Cells["D4"]; | |
cell.Value = -2000.00; | |
style = cell.GetStyle(); | |
// For "#,##0" format | |
style.NumberFormat = 3; | |
cell.SetStyle(style); | |
// Accessing a cell and setting its value & font | |
cell = sheet.Cells["B6"]; | |
cell.Value = "Currency"; | |
cell.SetFont(font); | |
// Accessing the Style object of "C6" cell and setting its number format to index No.6 | |
cell = sheet.Cells["C6"]; | |
cell.Value = -120.00; | |
style = cell.GetStyle(); | |
// For Applying "\"$\"#,##0_);[Red](\"$\"#,##0)" expression | |
style.NumberFormat = 6; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D6" cell and setting its number format to index No.41 | |
cell = sheet.Cells["D6"]; | |
cell.Value = 2400; | |
style = cell.GetStyle(); | |
// For applying "_(\"$\"* #,##0_);_(\"$\"* (#,##0);_(\"$\"* \"-\"_);_(@_)" expression | |
style.NumberFormat = 41; | |
cell.SetStyle(style); | |
// Accessing a cell and setting its value & font | |
cell = sheet.Cells["B8"]; | |
cell.Value = "Percent"; | |
cell.SetFont(font); | |
// Accessing the Style object of "C8" cell and setting its number format to index No.9 | |
cell = sheet.Cells["C8"]; | |
cell.Value = 0.32; | |
style = cell.GetStyle(); | |
style.NumberFormat = 9; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D8" cell and setting its number format to index No.10 | |
cell = sheet.Cells["D8"]; | |
cell.Value = 0.64; | |
style = cell.GetStyle(); | |
// For applying "0.00%" format | |
style.NumberFormat = 10; | |
cell.SetStyle(style); | |
// Accessing a cell and setting its value & font | |
cell = sheet.Cells["B10"]; | |
cell.Value = "Scientific"; | |
cell.SetFont(font); | |
// Accessing the Style object of "C10" cell and setting its number format to index No.11 | |
cell = sheet.Cells["C10"]; | |
cell.Value = 0.51; | |
style = cell.GetStyle(); | |
// For applying "0.00E+00" format | |
style.NumberFormat = 11; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D10" cell and setting its number format to index No.48 | |
cell = sheet.Cells["D10"]; | |
cell.Value = 32000; | |
style = cell.GetStyle(); | |
style.NumberFormat = 48; | |
cell.SetStyle(style); | |
// Accessing a cell and setting its value & font | |
cell = sheet.Cells["B12"]; | |
cell.Value = "DateTime"; | |
cell.SetFont(font); | |
// Accessing the Style object of "C12" cell and setting a custom number format for it | |
cell = sheet.Cells["C12"]; | |
cell.Value = DateTime.Now; | |
style = cell.GetStyle(); | |
style.Custom = "yyyy-MM-dd"; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D12" cell and setting its number format to Index No.15 | |
cell = sheet.Cells["D12"]; | |
sheet.Columns[cell.Column].Width = 100; | |
cell.Value = DateTime.Now; | |
style = cell.GetStyle(); | |
// For "d-mmm-yy" | |
style.NumberFormat = 15; | |
cell.SetStyle(style); | |
// Accessing the Style object of "C13" cell and setting a custom number format for it | |
cell = sheet.Cells["C13"]; | |
cell.Value = DateTime.Now; | |
style = cell.GetStyle(); | |
style.Custom = "hh:mm:ss"; | |
cell.SetStyle(style); | |
// Accessing the Style object of "D13" cell and setting its number format to index No.18 | |
cell = sheet.Cells["D13"]; | |
cell.Value = DateTime.Now; | |
style = cell.GetStyle(); | |
// For applying "h:mm AM/PM" format | |
style.NumberFormat = 18; | |
cell.SetStyle(style); | |
// Accessing the Style object of "C14" cell and setting a custom number format for it | |
cell = sheet.Cells["C14"]; | |
sheet.Columns[cell.Column].Width = 160; | |
cell.Value = DateTime.Now; | |
style = cell.GetStyle(); | |
style.Custom = "yyyy-MM-dd hh:mm:ss"; | |
cell.SetStyle(style); |
This file contains 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 first worksheet of the Grid | |
Aspose.Cells.GridDesktop.Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing "B2" cell and setting its value | |
Aspose.Cells.GridDesktop.GridCell cell = sheet.Cells["B2"]; | |
cell.Value = "None"; | |
// Accessing "D4" cell and setting its value & column width | |
cell = sheet.Cells["D4"]; | |
cell.Value = "out line Borders"; | |
sheet.Columns[cell.Column].Width = 120; | |
// Accessing the Style object of "D4" cell and drawing thin red borders around it | |
Aspose.Cells.GridDesktop.Style style = cell.GetStyle(); | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Top, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Red); | |
cell.SetStyle(style); | |
// Accessing "B6" cell and setting its value, row height & column width | |
cell = sheet.Cells["B6"]; | |
cell.Value = "Border with\ndifferent colors"; | |
sheet.Rows[cell.Row].Height = 40; | |
sheet.Columns[cell.Column].Width = 110; | |
// Accessing the Style object of "B6" cell and drawing thin borders of different colors around it | |
style = cell.GetStyle(); | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Green); | |
style.SetBorderLine(BorderType.Top, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Yellow); | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Blue); | |
cell.SetStyle(style); | |
// Accessing "D7" cell and setting its value, row height & column width | |
cell = sheet.Cells["D7"]; | |
cell.Value = "Border with\ndifferent styles"; | |
sheet.Rows[cell.Row].Height = 40; | |
sheet.Columns[cell.Column].Width = 110; | |
// Accessing the Style object of "D7" cell and drawing different borders of different colors around it | |
style = cell.GetStyle(); | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin); | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Right, BorderLineType.Medium); | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Red); | |
style.SetBorderLine(BorderType.Top, BorderLineType.Dashed); | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Yellow); | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Dotted); | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Black); | |
cell.SetStyle(style); | |
// Accessing "B8" cell and drawing a single red border to its bottom side | |
cell = sheet.Cells["B8"]; | |
cell.Value = "Only one border"; | |
style = cell.GetStyle(); | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.MediumDashDotted); | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Red); | |
cell.SetStyle(style); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Creating a customized Font object | |
Font font = new Font("Arial", 10, FontStyle.Bold); | |
// Setting the font of the cell to the customized Font object | |
cell.SetFont(font); | |
// Setting the font color of the cell to Blue | |
cell.SetFontColor(Color.Blue); |
This file contains 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 | |
// Enable GridDesktop's auto-filter. | |
gridDesktop1.Worksheets[0].RowFilter.EnableAutoFilter = true; | |
// Set the header row. | |
gridDesktop1.Worksheets[0].RowFilter.HeaderRow = 0; | |
// Set the starting row. | |
gridDesktop1.Worksheets[0].RowFilter.StartRow = 1; | |
// Set the ending row. | |
gridDesktop1.Worksheets[0].RowFilter.EndRow = 101; |
This file contains 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 | |
// Set the starting row. | |
gridDesktop1.Worksheets[0].RowFilter.StartRow = 1; | |
// Set the ending row. | |
gridDesktop1.Worksheets[0].RowFilter.EndRow = 101; | |
// Get the RowFilter object for the first worksheet. | |
RowFilterSettings rowFilter = gridDesktop1.Worksheets[0].RowFilter; | |
// Filter Rows. | |
rowFilter.FilterRows(0, "Customer 1"); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Setting sample values | |
GridCell cell = sheet.Cells["b7"]; | |
cell.SetCellValue("1"); | |
cell = sheet.Cells["c7"]; | |
cell.SetCellValue("2"); | |
cell = sheet.Cells["d7"]; | |
cell.SetCellValue("3"); | |
cell = sheet.Cells["e7"]; | |
cell.SetCellValue("4"); | |
// Creating a CellRange object starting from "B7" to "E7" | |
CellRange range = new CellRange(6, 1, 6, 4); | |
// Accessing and setting Style attributes | |
Style style = new Style(this.gridDesktop1); | |
style.Color = Color.Yellow; | |
// Applying Style object on the range of cells | |
sheet.SetStyle(range, style); | |
// Creating a customized Font object | |
Font font = new Font("Courier New", 12f); | |
// Setting the font of range of cells to the customized Font object | |
sheet.SetFont(range, font); | |
// Setting the font color of range of cells to Red | |
sheet.SetFontColor(range, Color.Red); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Creating a CellRange object starting from "B4" to "C6" | |
CellRange range = new CellRange("B4", "C6"); | |
// Merging a range of cells | |
sheet.Merge(range); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the merged cell that is currently in focus | |
GridCell cell = sheet.GetFocusedCell(); | |
// Unmerging a cell using its location | |
sheet.Unmerge(cell.Location); |
This file contains 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 | |
// Create the UndoManager object | |
UndoManager um = gridDesktop1.UndoManager; | |
// Perform Redo operation | |
um.Redo(); |
This file contains 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 | |
// Enable the Undo operation | |
gridDesktop1.EnableUndo = true; | |
// Create the UndoManager object | |
UndoManager um = gridDesktop1.UndoManager; | |
// Perform Undo operation | |
um.Undo(); |
This file contains 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 | |
// Ending format painter to stop painting | |
gridDesktop1.EndFormatPainter(); |
This file contains 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 | |
// Starting format painter to keep painting forever | |
gridDesktop1.StartFormatPainter(true); |
This file contains 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 | |
// Starting format painter to paint once | |
gridDesktop1.StartFormatPainter(false); |
This file contains 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 | |
// Clear the Worsheets first | |
_grid.Clear(); | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Specifying the path of Excel file using ImportExcelFile method of the control | |
_grid.ImportExcelFile(dataDir + "book1.xlsx"); | |
// Apply a formula to a cell that refers to a named range "Rang1" | |
_grid.Worksheets[0].Cells["G6"].SetCellValue("=SUM(Range1)"); | |
// Add a new named range "MyRange" with based area A2:B5 | |
int index = _grid.Names.Add("MyRange", "Sheet1!A2:B5"); | |
// Apply a formula to G7 cell | |
_grid.Worksheets[0].Cells["G7"].SetCellValue("=SUM(MyRange)"); | |
// Calculate the results of the formulas | |
_grid.RunAllFormulas(); | |
// Save the Excel file | |
_grid.ExportExcelFile(dataDir + @"ouputBook1_out.xlsx"); |
This file contains 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 void gridDesktop1_CellClick(object sender, Aspose.Cells.GridDesktop.CellEventArgs e) | |
{ | |
MessageBox.Show("Cell is clicked"); | |
} |
This file contains 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 | |
// | |
// gridDesktop1 | |
// | |
this.gridDesktop1.ActiveSheetIndex = 0; | |
this.gridDesktop1.ActiveSheetNameFont = null; | |
this.gridDesktop1.CommentDisplayingFont = new System.Drawing.Font("Arial", 9F); | |
this.gridDesktop1.Dock = System.Windows.Forms.DockStyle.Fill; | |
this.gridDesktop1.IsHorizontalScrollBarVisible = true; | |
this.gridDesktop1.IsVerticalScrollBarVisible = true; | |
this.gridDesktop1.Location = new System.Drawing.Point(0, 0); | |
this.gridDesktop1.Name = "gridDesktop1"; | |
this.gridDesktop1.SheetNameFont = new System.Drawing.Font("Verdana", 8F); | |
this.gridDesktop1.SheetTabWidth = 400; | |
this.gridDesktop1.Size = new System.Drawing.Size(657, 452); | |
this.gridDesktop1.TabIndex = 0; | |
this.gridDesktop1.CellClick += new Aspose.Cells.GridDesktop.CellEventHandler(this.gridDesktop1_CellClick); | |
// | |
// GridDesktopEvents | |
// |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Specifying the path of Excel file using ImportExcelFile method of the control | |
gridDesktop1.ImportExcelFile(dataDir + "SampleCSV1.csv"); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Specifying the path of Excel file using ImportExcelFile method of the control | |
gridDesktop1.ImportExcelFile(dataDir + "Sample.xlsx"); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Opening an Excel file as a stream | |
FileStream fs = File.OpenRead(dataDir + "Sample.xlsx"); | |
// Loading the Excel file contents into the control from a stream | |
gridDesktop1.ImportExcelFile(fs); | |
// Closing stream | |
fs.Close(); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Saving Grid contents to an Excel file | |
gridDesktop1.ExportExcelFile(dataDir + "book1_out.xls"); | |
// Saving Grid contents to MS Excel 2007 Xlsx file format | |
gridDesktop1.ExportExcelFile(Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) + "book1_out.xlsx", FileFormatType.Excel2007Xlsx); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Opening an Excel file as a stream | |
FileStream fs = File.Open(dataDir + "book1_out.xls", FileMode.Open, FileAccess.ReadWrite); | |
// Saving Grid contents of the control to a stream | |
gridDesktop1.ExportExcelFile(fs); | |
// Closing stream | |
fs.Close(); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding checkbox to a specific column of the Worksheet | |
sheet.Columns[2].AddCheckBox(); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Creating an array of items or values that will be added to combobox | |
string[] items = new string[3]; | |
items[0] = "Aspose"; | |
items[1] = "Aspose.Grid"; | |
items[2] = "Aspose.Grid.Desktop"; | |
// Adding combobox (containing items) to a specific column of the Worksheet | |
sheet.Columns[2].AddComboBox(items); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding column to the worksheet | |
sheet.AddColumn(); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Inserting column to the worksheet to the first position. | |
gridDesktop1.Worksheets[0].InsertColumn(0); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding row to the worksheet | |
sheet.AddRow(); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Inserting row to the worksheet to the first position. | |
gridDesktop1.Worksheets[0].InsertRow(0); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the first column of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; | |
// Adding sample value to sheet cell | |
GridCell cell = sheet.Cells["a1"]; | |
cell.SetCellValue("Aspose"); | |
// Getting the Style object for the column | |
Style style = column.GetStyle(); | |
// Setting Style properties i.e. border, alignment color etc. | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thick); | |
style.SetBorderColor(BorderType.Right, Color.Blue); | |
style.HAlignment = HorizontalAlignmentType.Centred; | |
// Setting the style of the column with the customized Style object | |
column.SetStyle(style); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the first row of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[0]; | |
// Getting the Style object for the row | |
//Style style = row.GetStyle(); | |
// Setting Style properties i.e. border, color, alignment, background color etc. | |
//style.SetBorderLine(BorderType.Right, BorderLineType.Thick); | |
//style.SetBorderColor(BorderType.Right, Color.Blue); | |
//style.HAlignment = HorizontalAlignmentType.Centred; | |
//style.Color = Color.Yellow; | |
// Setting the style of the row with the customized Style object | |
//row.SetStyle(style); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Setting the number of frozen columns to 2 | |
sheet.FrozenCols = 2; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Setting the number of frozen rows to 2 | |
sheet.FrozenRows = 2; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Setting the number of frozen columns to 0 for unfreezing columns | |
sheet.FrozenCols = 0; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Setting the number of frozen rows to 0 for unfreezing rows | |
sheet.FrozenRows = 0; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing cell control in the column and typecasting it to CheckBox | |
Aspose.Cells.GridDesktop.CheckBox cb = (Aspose.Cells.GridDesktop.CheckBox)sheet.Columns[2].CellControl; | |
if (cb != null) | |
{ | |
// Modifying the Checked property of CheckBox | |
cb.Checked = true; | |
} | |
else | |
{ | |
MessageBox.Show("Please add control before accessing it."); | |
} |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Removing cell control from the column | |
sheet.Columns[2].RemoveCellControl(); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Removing the first column of the worksheet | |
sheet.RemoveColumn(0); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Removing the first row of the worksheet | |
sheet.RemoveRow(0); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cell | |
GridCell cell = sheet.Cells["a1"]; | |
cell.SetCellValue("Welcome to Aspose!"); | |
// Accessing the first column of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; | |
// Setting the width of the column | |
column.Width = 150; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cells | |
GridCell cell = sheet.Cells["b2"]; | |
cell.SetCellValue("1"); | |
cell = sheet.Cells["c2"]; | |
cell.SetCellValue("2"); | |
cell = sheet.Cells["d2"]; | |
cell.SetCellValue("3"); | |
cell = sheet.Cells["e2"]; | |
cell.SetCellValue("4"); | |
// Accessing the first row of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[1]; | |
// Setting the height of the row | |
row.Height = 100; |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing the Validation object applied on a specific column | |
//Validation validation = sheet.Columns[2].Validation; | |
// Editing the attributes of Validation | |
//validation.IsRequired = true; | |
//validation.RegEx = ""; | |
//validation.CustomValidation = null; |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding Is Required Validation to a column | |
sheet.Columns[2].AddValidation(true, ""); | |
// Adding simple Regular Expression Validation to a column | |
sheet.Columns[4].AddValidation(true, @"\d+"); | |
// Adding complex Regular Expression Validation to a column | |
sheet.Columns[6].AddValidation(true, @"\d{4}-\d{2}-\d{2}"); | |
// Adding Custom Validation to a column | |
sheet.Columns[8].AddValidation(new CustomValidation()); |
This file contains 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 | |
// Implementing ICustomValidation interface | |
public class CustomValidation : Aspose.Cells.GridDesktop.ICustomValidation | |
{ | |
// Implementing Validate method already defined in the interface | |
public bool Validate(Worksheet worksheet, int row, int col, object value) | |
{ | |
// Checking the cell's address | |
if (row == 7 && col == 0) | |
{ | |
//Checking the data type of cell's value | |
double d = 0; | |
try | |
{ | |
d = (double)value; | |
} | |
catch | |
{ | |
return false; | |
} | |
// Checking if the cell's value is greater than 100 | |
if (d > 100) | |
return true; | |
} | |
return false; | |
} | |
} |
This file contains 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 first worksheet of the Grid | |
//Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Removing the Validation applied on a specific column | |
//sheet.Columns[2].RemoveValidation(); |
This file contains 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 | |
// Accesing an active worksheet using its index | |
Worksheet sheet = gridDesktop1.Worksheets[gridDesktop1.ActiveSheetIndex]; |
This file contains 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 | |
// Accesing an active worksheet directly | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); |
This file contains 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 | |
// Accesing a worksheet using its index | |
Worksheet sheet = gridDesktop1.Worksheets[0]; |
This file contains 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 | |
// Accesing a worksheet using its name | |
Worksheet sheet = gridDesktop1.Worksheets["Sheet2"]; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the location of the cell that is currently in focus | |
CellLocation cl = sheet.GetFocusedCellLocation(); | |
// Adding checkbox to the Controls collection of the Worksheet | |
sheet.Controls.AddCheckBox(cl.Row, cl.Column, true); |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing the location of the cell that is currently in focus | |
CellLocation cl = sheet.GetFocusedCellLocation(); | |
// Creating an array of items or values that will be added to combobox | |
string[] items = new string[3]; | |
items[0] = "Aspose"; | |
items[1] = "Aspose.Grid"; | |
items[2] = "Aspose.Grid.Desktop"; | |
// Adding combobox to the Controls collection of the Worksheet | |
sheet.Controls.AddComboBox(cl.Row, cl.Column, items); |
This file contains 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 | |
// Implenting CellCheckedChanged event handler | |
private void gridDesktop1_CellCheckedChanged(object sender, CellControlEventArgs e) | |
{ | |
// Getting the reference of the CheckBox control whose event is triggered | |
Aspose.Cells.GridDesktop.CheckBox check = (Aspose.Cells.GridDesktop.CheckBox)gridDesktop1.GetActiveWorksheet().Controls[e.Row, e.Column]; | |
// Displaying the message when the Checked state of CheckBox is changed | |
MessageBox.Show("Current state of CheckBox is " + check.Checked); | |
} |
This file contains 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 | |
// Implenting CellSelectedIndexChanged event handler | |
private void gridDesktop1_CellSelectedIndexChanged(object sender, CellComboBoxEventArgs e) | |
{ | |
// Getting the reference of the ComboBox control whose event is triggered | |
Aspose.Cells.GridDesktop.ComboBox combo = | |
(Aspose.Cells.GridDesktop.ComboBox)gridDesktop1.GetActiveWorksheet().Controls[e.Row, e.Column]; | |
// Displaying the message when the Selected Index of ComboBox is changed | |
MessageBox.Show(combo.Items[combo.SelectedIndex].ToString()); | |
} |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Set the image. | |
Image image = Image.FromFile(dataDir + @"AsposeLogo.jpg"); | |
button.Image = image; |
This file contains 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 the Grid | |
int i = gridDesktop1.Worksheets.Add(); | |
Worksheet sheet = gridDesktop1.Worksheets[i]; |
This file contains 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 the Grid with a specific name | |
Worksheet sheet1 = gridDesktop1.Worksheets.Add("AddWorksheetWithName"); |
This file contains 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 a worksheet to Grid at first position of the worksheets collection | |
gridDesktop1.Worksheets.Insert(0); |
This file contains 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 a worksheet to Grid at first position with a specific sheet name | |
Worksheet sheet1 = gridDesktop1.Worksheets.Insert(0, "InsertWorksheetWithName"); |
This file contains 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 | |
// Hiding the vertical scroll bar | |
gridDesktop1.IsVerticalScrollBarVisible = false; | |
// Hiding the horizontal scroll bar | |
gridDesktop1.IsHorizontalScrollBarVisible = false; |
This file contains 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 | |
// Displaying the vertical scroll bar | |
gridDesktop1.IsVerticalScrollBarVisible = true; | |
// Displaying the horizontal scroll bar | |
gridDesktop1.IsHorizontalScrollBarVisible = true; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
//Getting the total number of rows and columns inside the worksheet | |
int totalRows = sheet.RowsCount; | |
int totalCols = sheet.ColumnsCount; | |
// Exporting the data of the active worksheet to a new DataTable object | |
DataTable table = sheet.ExportDataTable(0, 0, totalRows, totalCols, false, true); |
This file contains 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("ProductName", System.Type.GetType("System.String")); | |
dataTable.Columns.Add("CategoryName", System.Type.GetType("System.String")); | |
dataTable.Columns.Add("QuantityPerUnit", System.Type.GetType("System.String")); | |
dataTable.Columns.Add("UnitsInStock", System.Type.GetType("System.Int32")); | |
// Exporting the data of the first worksheet of the Grid to the specific DataTable object | |
dataTable = gridDesktop1.Worksheets[0].ExportDataTable(dataTable, 0, 0, 69, 4, true); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
OleDbDataAdapter adapter; | |
DataTable dt = new DataTable(); | |
// Creating connection string to connect with database | |
string conStr = @"Provider=microsoft.jet.oledb.4.0;Data Source=" + dataDir + "dbDatabase.mdb"; | |
// Creating Select query to fetch data from database | |
string query = "SELECT * FROM Products ORDER BY ProductID"; | |
adapter = new OleDbDataAdapter(query, conStr); | |
// Filling DataTable using an already created OleDbDataAdapter object | |
adapter.Fill(dt); | |
// Accessing the reference of a worksheet | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Importing data from DataTable to the worksheet. 0,0 specifies to start importing data from the cell with first row (0 index) and first column (0 index) | |
sheet.ImportDataTable(dt, false, 0, 0); | |
// Iterating through the number of columns contained in the DataTable | |
for (int i = 0; i < dt.Columns.Count; i++) | |
{ | |
// Setting the column headers of the worksheet according to column names of the DataTable | |
sheet.Columns[i].Header = dt.Columns[i].Caption; | |
} | |
// Setting the widths of the columns of the worksheet | |
sheet.Columns[0].Width = 240; | |
sheet.Columns[1].Width = 160; | |
sheet.Columns[2].Width = 160; | |
sheet.Columns[3].Width = 100; | |
// Displaying the contents of the worksheet by making it active | |
gridDesktop1.ActiveSheetIndex = 0; |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Getting the location of the cell that is currently in focus | |
CellLocation cl = sheet.GetFocusedCellLocation(); | |
// Accessing cell control and typecasting it to CheckBox | |
Aspose.Cells.GridDesktop.CheckBox cb = (Aspose.Cells.GridDesktop.CheckBox)sheet.Controls[cl.Row, cl.Column]; | |
if (cb != null) | |
{ | |
// Modifying the Checked property of CheckBox | |
cb.Checked = true; | |
} | |
else | |
{ | |
MessageBox.Show("Please add control before accessing it."); | |
} |
This file contains 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 | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Getting the location of the cell that is currently in focus | |
CellLocation cl = sheet.GetFocusedCellLocation(); | |
// Removing the cell control by specifying the location of cell containing it | |
sheet.Controls.Remove(cl.Row, cl.Column); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a comment added to "c3" cell (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridComment comment1 = sheet.Comments[3, 1]; | |
if (comment1 != null) | |
{ | |
// Modifying the text of comment | |
comment1.Text = "The 1st comment."; | |
MessageBox.Show("Comment has been modified"); | |
} | |
else | |
{ | |
MessageBox.Show("Please add comment before accessing it."); | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding comment to "b2" cell | |
sheet.Comments.Add("b2", "Please write your name."); | |
// Adding another comment to "b4" cell using its row & column number | |
sheet.Comments.Add(3, 1, "Please write your email."); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Comments[3, 1] != null) | |
{ | |
// Removing comment from "c3" cell | |
sheet.Comments.Remove(3, 1); | |
MessageBox.Show("Comment has been removed"); | |
} | |
else | |
{ | |
MessageBox.Show("Please add comment before removing it."); | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a hyperlink added to "c3,b2" cells (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridHyperlink hyperlink1 = sheet.Hyperlinks[2, 2]; | |
Aspose.Cells.GridDesktop.Data.GridHyperlink hyperlink2 = sheet.Hyperlinks[1, 1]; | |
if (hyperlink1 != null && hyperlink2 != null) | |
{ | |
// Modifying the Url of the hyperlink | |
hyperlink1.Url = "www.aspose.com"; | |
hyperlink2.Url = "www.aspose.com"; | |
MessageBox.Show("Hyperlinks are accessed and URL's are: \n" + hyperlink1.Url + "\n" + hyperlink2.Url); | |
} | |
else | |
{ | |
MessageBox.Show("No hyperlinks are found in sheet. Add hyperlinks first."); | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing cell of the worksheet | |
GridCell cell = sheet.Cells["b2"]; | |
GridCell cell2 = sheet.Cells["c3"]; | |
// Modifying the width of the column of the cell | |
sheet.Columns[cell.Column].Width = 160; | |
sheet.Columns[cell2.Column].Width = 160; | |
// Adding a value to the cell | |
cell.Value = "Aspose Home"; | |
cell2.Value = "Aspose Home"; | |
// Adding a hyperlink to the worksheet containing cell name and the hyperlink URL with which the cell will be linked | |
sheet.Hyperlinks.Add("b2", "www.aspose.com"); | |
sheet.Hyperlinks.Add("c3", "www.aspose.com"); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Hyperlinks.Count > 0) | |
{ | |
// Removing hyperlink from "c3" cell | |
sheet.Hyperlinks.Remove(2, 2); | |
MessageBox.Show("Hyperlink in C3 cell has been removed."); | |
} | |
else | |
{ | |
MessageBox.Show("No hyperlinks are found in sheet to remove. Add hyperlinks first."); | |
} |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a picture added to "c3" cell (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridPicture picture1 = sheet.Pictures[1]; | |
// Modifying the image | |
picture1.Image = Image.FromFile(dataDir + "Aspose.Grid.jpg"); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding picture to "b2" cell from file | |
sheet.Pictures.Add("b2", dataDir + "AsposeGrid.jpg"); | |
// Creating a stream contain picture | |
FileStream fs = new FileStream(dataDir + "AsposeLogo.jpg", FileMode.Open); | |
try | |
{ | |
// Adding picture to "b3" cell from stream | |
sheet.Pictures.Add(2, 1, fs); | |
} | |
catch (Exception ex) | |
{ | |
MessageBox.Show(ex.Message); | |
} | |
finally | |
{ | |
// Closing stream | |
fs.Close(); | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Removing picture from "c3" cell | |
sheet.Pictures.Remove(2, 2); |
This file contains 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 | |
// Move the 2nd worksheet to 4th position. | |
gridDesktop1.Worksheets.MoveTo(1, 3); |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Import sample excel file in GridDesktop | |
gridDesktop1.ImportExcelFile(dataDir + "ValidationTesting.xlsx"); |
This file contains 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 index | |
gridDesktop1.Worksheets.Remove(0); |
This file contains 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 index | |
gridDesktop1.Worksheets.RemoveAt("Sheet3"); |
This file contains 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 | |
// Accesing an active worksheet directly | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Renaming a worksheet | |
sheet.Name = "Renamed Sheet"; |
This file contains 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 that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Creating SortRange object | |
SortRange sr = new SortRange(sheet, range.StartRow, | |
range.StartColumn, range.EndRow - range.StartRow + 1, | |
range.EndColumn - range.StartColumn + 1, | |
SortOrientation.SortTopToBottom, true); | |
// Sorting data in the specified column in ascending order | |
sr.Sort(range.StartColumn, Aspose.Cells.GridDesktop.SortOrder.Ascending); | |
// Redrawing cells of the Grid | |
gridDesktop1.Invalidate(); |
This file contains 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 global variable of CellRange | |
CellRange range; | |
private void gridDesktop1_SelectedCellRangeChanged(object sender, Aspose.Cells.GridDesktop.CellRangeEventArgs e) | |
{ | |
// Checking if the range of cells is not empty | |
if ((e.CellRange.EndColumn - e.CellRange.StartColumn > 0) || | |
(e.CellRange.EndRow - e.CellRange.StartRow > 0)) | |
{ | |
// Assigning the updated CellRange to global variable | |
range = e.CellRange; | |
} | |
} |
This file contains 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 that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Creating SortRange object | |
SortRange sr = new SortRange(sheet, range.StartRow, range.StartColumn, | |
range.EndRow - range.StartRow + 1, | |
range.EndColumn - range.StartColumn + 1, | |
SortOrientation.SortTopToBottom, true); | |
// Sorting data in the specified column in descending order | |
sr.Sort(range.StartColumn, Aspose.Cells.GridDesktop.SortOrder.Descending); | |
// Redrawing cells of the Grid | |
gridDesktop1.Invalidate(); |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Validations.Count > 0) | |
{ | |
// Accessing the Validation object applied on "a8" cell | |
Aspose.Cells.GridDesktop.Data.GridValidation validation = sheet.Validations[7, 0]; | |
// Editing the attributes of Validation | |
validation.IsRequired = true; | |
validation.RegEx = ""; | |
validation.CustomValidation = null; | |
MessageBox.Show("Validation has been edited after accessing it."); | |
} | |
else | |
{ | |
MessageBox.Show("No validations found to access."); | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding values to specific cells of the worksheet | |
sheet.Cells["a2"].Value = "Required"; | |
sheet.Cells["a4"].Value = "100"; | |
sheet.Cells["a6"].Value = "2006-07-21"; | |
sheet.Cells["a8"].Value = "101.2"; | |
// Adding Is Required Validation to a cell | |
sheet.Validations.Add("a2", true, ""); | |
// Adding simple Regular Expression Validation to a cell | |
sheet.Validations.Add("a4", true, @"\d+"); | |
// Adding complex Regular Expression Validation to a cell | |
sheet.Validations.Add("a6", true, @"\d{4}-\d{2}-\d{2}"); | |
// Adding Custom Validation to a cell | |
sheet.Validations.Add("a8", new CustomValidation()); |
This file contains 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 | |
// Implementing ICustomValidation interface | |
public class CustomValidation : Aspose.Cells.GridDesktop.ICustomValidation | |
{ | |
// Implementing Validate method already defined in the interface | |
public bool Validate(Worksheet worksheet, int row, int col, object value) | |
{ | |
// Checking the cell's address | |
if (row == 7 && col == 0) | |
{ | |
//Checking the data type of cell's value | |
double d = 0; | |
try | |
{ | |
d = (double)value; | |
} | |
catch | |
{ | |
return false; | |
} | |
// Checking if the cell's value is greater than 100 | |
if (d > 100) | |
return true; | |
} | |
return false; | |
} | |
} |
This file contains 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Validations.Count > 0) | |
{ | |
// Removing the Validation object applied on "a6" cell | |
sheet.Validations.RemoveAt(1); | |
MessageBox.Show("Validation has been removed."); | |
} | |
else | |
{ | |
MessageBox.Show("No validations found to remove."); | |
} |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Importing the template Excel file to GridDesktop | |
gridDesktop1.ImportExcelFile(dataDir + "EmployeeSales.xlsx"); | |
// Set the default value of the TrackBar control | |
trackBar1.Value = 100; | |
// Set the custom label's text to the trackbar's value for display | |
label1.Text = trackBar1.Value.ToString() + "%"; |
This file contains 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 | |
// Set the Zoom factor of the active worksheet to the Trackbar's value | |
gridDesktop1.Worksheets[gridDesktop1.GetActiveWorksheet().Index].Zoom = trackBar1.Value; | |
// Show the percentage value of the specified Zoom | |
label1.Text = trackBar1.Value.ToString() + "%"; |
This file contains 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 | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
using (var stream = new MemoryStream(System.IO.File.ReadAllBytes(dataDir + "SampleBook.xlsx"))) | |
{ | |
this.grid.ImportExcelFile(stream); | |
this.grid.ExportExcelFile(dataDir + "SampleOutput_out.xlsx"); | |
} |
This file contains 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 | |
' Indicates whether to copy/paste based on clipboard, so that it can copy/paste with MS-EXCEL. | |
' It will only copy/paste cell value and will not copy any other setting of the cell like format, border style and so on. | |
' The default value is false. | |
gridDesktop1.EnableClipboardCopyPaste = True |
This file contains 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 namespace to the top of code | |
Imports System.Data.OleDb |
This file contains 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 new row to the worksheet | |
gridDesktop1.GetActiveWorksheet().AddRow() |
This file contains 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 | |
' Iterating through each column of the worksheet | |
For i As Integer = 0 To sheet.ColumnsCount - 1 | |
' Getting the style object of each column | |
Dim style As Style = sheet.Columns(i).GetStyle() | |
' Setting the color of each column to Yellow | |
style.Color = Color.Yellow | |
' Setting the Horizontal Alignment of each column to Centered | |
style.HAlignment = HorizontalAlignmentType.Centred | |
' Setting the style of column to the updated one | |
sheet.Columns(i).SetStyle(style) | |
Next |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Binding the Worksheet to Products table by calling its DataBind method | |
sheet.DataBind(ds.Tables("Products"), "") |
This file contains 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 | |
' Customizing the widths of columns of the worksheet | |
sheet.Columns(0).Width = 70 | |
sheet.Columns(1).Width = 120 | |
sheet.Columns(2).Width = 80 |
This file contains 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 | |
' Declaring global variable | |
Private adapter As OleDbDataAdapter | |
Private cb As OleDbCommandBuilder | |
Private ds As DataSet |
This file contains 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 | |
' Getting the index of the focused row | |
Dim focusedRowIndex As Integer = gridDesktop1.GetActiveWorksheet().GetFocusedCell().Row | |
' Removing the focused row fro the worksheet | |
gridDesktop1.GetActiveWorksheet().RemoveRow(focusedRowIndex) |
This file contains 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 Sub DataBindingFeatures_Load(sender As Object, e As EventArgs) | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Creating Select query to fetch data from database | |
Dim query As String = "SELECT * FROM Products ORDER BY ProductID" | |
' Creating connection string to connect with database | |
Dim conStr As String = "Provider=microsoft.jet.oledb.4.0;Data Source=" & dataDir & "dbDatabase.mdb" | |
' Creating OleDbDataAdapter object that will be responsible to open/close connections with database, fetch data and fill DataSet with data | |
adapter = New OleDbDataAdapter(query, conStr) | |
' Setting MissingSchemaAction to AddWithKey for getting necesssary primary key information of the tables | |
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey | |
' Creating OleDbCommandBuilder object to create insert/delete SQL commmands | |
' automatically that are used by OleDbDatAdapter object for updating | |
' changes to the database | |
cb = New OleDbCommandBuilder(adapter) | |
' Creating DataSet object | |
ds = New DataSet() | |
' Filling DataSet with data fetched by OleDbDataAdapter object | |
adapter.Fill(ds, "Products") | |
End Sub |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Updating the database according to worksheet data source | |
adapter.Update(DirectCast(sheet.DataSource, DataTable)) |
This file contains 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 | |
' Iterating through all columns of the Products table in DataSet | |
For i As Integer = 0 To ds.Tables("Products").Columns.Count - 1 | |
' Setting the column header of each column to the column caption of Products table | |
sheet.Columns(i).Header = ds.Tables("Products").Columns(i).Caption | |
Next |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the cell using its name | |
Dim cell As GridCell = sheet.Cells("A1") | |
' Setting the value of "A1" cell | |
cell.SetCellValue(DateTime.Now) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the cell using its name | |
Dim cell As GridCell = sheet.Cells("A1") | |
' Accessing & modifying the value of "A1" cell | |
cell.Value = DateTime.Now |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing a cell using its row and column indices | |
Dim cell As GridCell = sheet.Cells(1, 1) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing a cell using its name | |
Dim cell As GridCell = sheet.Cells("A1") |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing a cell that is currently in focus | |
Dim cell As GridCell = sheet.GetFocusedCell() |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Make sure sheet has been protected | |
sheet.[Protected] = True | |
' Choose a cell range | |
Dim range As CellRange = sheet.CreateRange("A1", "B1") | |
' Set protected range area on Worksheet | |
sheet.SetProtected(range, True) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding numeric values to "B2" & "B3" cells | |
sheet.Cells("B2").SetCellValue(3) | |
sheet.Cells("B3").SetCellValue(4) | |
' Adding a formula to "B4" cell multiplying the values of "B2" & "B3" cells | |
sheet.Cells("B4").SetCellValue("=B2 * B3") | |
' Running all formulas in the Grid | |
gridDesktop1.RunAllFormulas() |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing "A1" cell in the worksheet | |
Dim cell As GridCell = sheet.Cells("A1") | |
' Adding a value to "A1" cell | |
cell.Value = "Hello" | |
' Getting the Style object for the cell | |
Dim style As Style = cell.GetStyle() | |
' Setting Style properties like border, alignment etc. | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thick) | |
style.SetBorderColor(BorderType.Right, Color.Blue) | |
style.HAlignment = HorizontalAlignmentType.Centred | |
style.Color = Color.Yellow | |
style.CellLocked = True | |
style.VAlignment = VerticalAlignmentType.Top | |
' Setting the style of the cell with the customized Style object | |
cell.SetStyle(style) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Aspose.Cells.GridDesktop.Worksheet = gridDesktop1.Worksheets(0) | |
' Creating a standard Font object that will be applied on cells | |
Dim font As New System.Drawing.Font("MS Serif", 9F, FontStyle.Bold) | |
' Accessing and adding values to cells | |
Dim cell As Aspose.Cells.GridDesktop.GridCell = sheet.Cells("B2") | |
cell.Value = "General" | |
cell.SetFont(font) | |
cell = sheet.Cells("C2") | |
cell.Value = 1000 | |
cell = sheet.Cells("D2") | |
cell.Value = "Text" | |
cell = sheet.Cells("B4") | |
cell.Value = "Number" | |
cell.SetFont(font) | |
'Accessing the Style object of "C4" cell and setting its number format to index No.2 | |
cell = sheet.Cells("C4") | |
cell.Value = 20.0 | |
Dim style As Aspose.Cells.GridDesktop.Style = cell.GetStyle() | |
' For applying "0.00" format | |
style.NumberFormat = 2 | |
cell.SetStyle(style) | |
' Accessing the Style object of "D4" cell and setting its number format to index No.3 | |
cell = sheet.Cells("D4") | |
cell.Value = -2000.0 | |
style = cell.GetStyle() | |
' For "#,##0" format | |
style.NumberFormat = 3 | |
cell.SetStyle(style) | |
' Accessing a cell and setting its value & font | |
cell = sheet.Cells("B6") | |
cell.Value = "Currency" | |
cell.SetFont(font) | |
' Accessing the Style object of "C6" cell and setting its number format to index No.6 | |
cell = sheet.Cells("C6") | |
cell.Value = -120.0 | |
style = cell.GetStyle() | |
' For Applying "\"$\"#,##0_);[Red](\"$\"#,##0)" expression | |
style.NumberFormat = 6 | |
cell.SetStyle(style) | |
' Accessing the Style object of "D6" cell and setting its number format to index No.41 | |
cell = sheet.Cells("D6") | |
cell.Value = 2400 | |
style = cell.GetStyle() | |
' For applying "_(\"$\"* #,##0_);_(\"$\"* (#,##0);_(\"$\"* \"-\"_);_(@_)" expression | |
style.NumberFormat = 41 | |
cell.SetStyle(style) | |
' Accessing a cell and setting its value & font | |
cell = sheet.Cells("B8") | |
cell.Value = "Percent" | |
cell.SetFont(font) | |
' Accessing the Style object of "C8" cell and setting its number format to index No.9 | |
cell = sheet.Cells("C8") | |
cell.Value = 0.32 | |
style = cell.GetStyle() | |
style.NumberFormat = 9 | |
cell.SetStyle(style) | |
' Accessing the Style object of "D8" cell and setting its number format to index No.10 | |
cell = sheet.Cells("D8") | |
cell.Value = 0.64 | |
style = cell.GetStyle() | |
' For applying "0.00%" format | |
style.NumberFormat = 10 | |
cell.SetStyle(style) | |
' Accessing a cell and setting its value & font | |
cell = sheet.Cells("B10") | |
cell.Value = "Scientific" | |
cell.SetFont(font) | |
' Accessing the Style object of "C10" cell and setting its number format to index No.11 | |
cell = sheet.Cells("C10") | |
cell.Value = 0.51 | |
style = cell.GetStyle() | |
' For applying "0.00E+00" format | |
style.NumberFormat = 11 | |
cell.SetStyle(style) | |
' Accessing the Style object of "D10" cell and setting its number format to index No.48 | |
cell = sheet.Cells("D10") | |
cell.Value = 32000 | |
style = cell.GetStyle() | |
style.NumberFormat = 48 | |
cell.SetStyle(style) | |
' Accessing a cell and setting its value & font | |
cell = sheet.Cells("B12") | |
cell.Value = "DateTime" | |
cell.SetFont(font) | |
' Accessing the Style object of "C12" cell and setting a custom number format for it | |
cell = sheet.Cells("C12") | |
cell.Value = DateTime.Now | |
style = cell.GetStyle() | |
style.[Custom] = "yyyy-MM-dd" | |
cell.SetStyle(style) | |
' Accessing the Style object of "D12" cell and setting its number format to Index No.15 | |
cell = sheet.Cells("D12") | |
sheet.Columns(cell.Column).Width = 100 | |
cell.Value = DateTime.Now | |
style = cell.GetStyle() | |
' For "d-mmm-yy" format | |
style.NumberFormat = 15 | |
cell.SetStyle(style) | |
' Accessing the Style object of "C13" cell and setting a custom number format for it | |
cell = sheet.Cells("C13") | |
cell.Value = DateTime.Now | |
style = cell.GetStyle() | |
style.[Custom] = "hh:mm:ss" | |
cell.SetStyle(style) | |
' Accessing the Style object of "D13" cell and setting its number format to index No.18 | |
cell = sheet.Cells("D13") | |
cell.Value = DateTime.Now | |
style = cell.GetStyle() | |
' For applying "h:mm AM/PM" format | |
style.NumberFormat = 18 | |
cell.SetStyle(style) | |
' Accessing the Style object of "C14" cell and setting a custom number format for it | |
cell = sheet.Cells("C14") | |
sheet.Columns(cell.Column).Width = 160 | |
cell.Value = DateTime.Now | |
style = cell.GetStyle() | |
style.[Custom] = "yyyy-MM-dd hh:mm:ss" | |
cell.SetStyle(style) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Aspose.Cells.GridDesktop.Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing "B2" cell and setting its value | |
Dim cell As Aspose.Cells.GridDesktop.GridCell = sheet.Cells("B2") | |
cell.Value = "None" | |
' Accessing "D4" cell and setting its value & column width | |
cell = sheet.Cells("D4") | |
cell.Value = "out line Borders" | |
sheet.Columns(cell.Column).Width = 120 | |
' Accessing the Style object of "D4" cell and drawing thin red borders around it | |
Dim style As Aspose.Cells.GridDesktop.Style = cell.GetStyle() | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Top, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Red) | |
cell.SetStyle(style) | |
' Accessing "B6" cell and setting its value, row height & column width | |
cell = sheet.Cells("B6") | |
cell.Value = "Border with" & vbLf & "different colors" | |
sheet.Rows(cell.Row).Height = 40 | |
sheet.Columns(cell.Column).Width = 110 | |
' Accessing the Style object of "B6" cell and drawing thin borders of different colors around it | |
style = cell.GetStyle() | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Green) | |
style.SetBorderLine(BorderType.Top, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Yellow) | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Blue) | |
cell.SetStyle(style) | |
' Accessing "D7" cell and setting its value, row height & column width | |
cell = sheet.Cells("D7") | |
cell.Value = "Border with" & vbLf & "different styles" | |
sheet.Rows(cell.Row).Height = 40 | |
sheet.Columns(cell.Column).Width = 110 | |
' Accessing the Style object of "D7" cell and drawing different borders of different colors around it | |
style = cell.GetStyle() | |
style.SetBorderLine(BorderType.Left, BorderLineType.Thin) | |
style.SetBorderColor(BorderType.Left, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Right, BorderLineType.Medium) | |
style.SetBorderColor(BorderType.Right, System.Drawing.Color.Red) | |
style.SetBorderLine(BorderType.Top, BorderLineType.Dashed) | |
style.SetBorderColor(BorderType.Top, System.Drawing.Color.Yellow) | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.Dotted) | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Black) | |
cell.SetStyle(style) | |
' Accessing "B8" cell and drawing a single red border to its bottom side | |
cell = sheet.Cells("B8") | |
cell.Value = "Only one border" | |
style = cell.GetStyle() | |
style.SetBorderLine(BorderType.Bottom, BorderLineType.MediumDashDotted) | |
style.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Red) | |
cell.SetStyle(style) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing a cell using its name | |
Dim cell As GridCell = sheet.Cells("A1") | |
' Creating a customized Font object | |
Dim font As New Font("Arial", 10, FontStyle.Bold) | |
' Setting the font of the cell to the customized Font object | |
cell.SetFont(font) | |
' Setting the font color of the cell to Blue | |
cell.SetFontColor(Color.Blue) |
This file contains 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 | |
' Enable GridDesktop's auto-filter. | |
gridDesktop1.Worksheets(0).RowFilter.EnableAutoFilter = True | |
' Set the header row. | |
gridDesktop1.Worksheets(0).RowFilter.HeaderRow = 0 | |
' Set the starting row. | |
gridDesktop1.Worksheets(0).RowFilter.StartRow = 1 | |
' Set the ending row. | |
gridDesktop1.Worksheets(0).RowFilter.EndRow = 101 |
This file contains 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 | |
' Set the starting row. | |
gridDesktop1.Worksheets(0).RowFilter.StartRow = 1 | |
' Set the ending row. | |
gridDesktop1.Worksheets(0).RowFilter.EndRow = 101 | |
' Get the RowFilter object for the first worksheet. | |
Dim rowFilter As RowFilterSettings = gridDesktop1.Worksheets(0).RowFilter | |
' Filter Rows. | |
rowFilter.FilterRows(0, "Customer 1") |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Setting sample values | |
Dim cell As GridCell = sheet.Cells("b7") | |
cell.SetCellValue("1") | |
cell = sheet.Cells("c7") | |
cell.SetCellValue("2") | |
cell = sheet.Cells("d7") | |
cell.SetCellValue("3") | |
cell = sheet.Cells("e7") | |
cell.SetCellValue("4") | |
' Creating a CellRange object starting from "B7" to "E7" | |
Dim range As New CellRange(6, 1, 6, 4) | |
' Accessing and setting Style attributes | |
Dim style As New Style(Me.gridDesktop1) | |
style.Color = Color.Yellow | |
' Applying Style object on the range of cells | |
sheet.SetStyle(range, style) | |
' Creating a customized Font object | |
Dim font As New Font("Courier New", 12F) | |
' Setting the font of range of cells to the customized Font object | |
sheet.SetFont(range, font) | |
' Setting the font color of range of cells to Red | |
sheet.SetFontColor(range, Color.Red) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Creating a CellRange object starting from "B4" to "C6" | |
Dim range As New CellRange("B4", "C6") | |
' Merging a range of cells | |
sheet.Merge(range) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the merged cell that is currently in focus | |
Dim cell As GridCell = sheet.GetFocusedCell() | |
' Unmerging a cell using its location | |
sheet.Unmerge(cell.Location) |
This file contains 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 | |
' Create the UndoManager object | |
Dim um As UndoManager = gridDesktop1.UndoManager | |
' Perform Redo operation | |
um.Redo() |
This file contains 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 | |
' Enable the Undo operation | |
gridDesktop1.EnableUndo = True | |
' Create the UndoManager object | |
Dim um As UndoManager = gridDesktop1.UndoManager | |
' Perform Undo operation | |
um.Undo() |
This file contains 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 | |
' Ending format painter to stop painting | |
gridDesktop1.EndFormatPainter() |
This file contains 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 | |
' Starting format painter to keep painting forever | |
gridDesktop1.StartFormatPainter(True) |
This file contains 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 | |
' Starting format painter to paint once | |
gridDesktop1.StartFormatPainter(False) |
This file contains 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 | |
' Clear the Worsheets first | |
_grid.Clear() | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Specifying the path of Excel file using ImportExcelFile method of the control | |
_grid.ImportExcelFile(dataDir & "book1.xlsx") | |
' Apply a formula to a cell that refers to a named range "Rang1" | |
_grid.Worksheets(0).Cells("G6").SetCellValue("=SUM(Range1)") | |
' Add a new named range "MyRange" with based area A2:B5 | |
Dim index As Integer = _grid.Names.Add("MyRange", "Sheet1!A2:B5") | |
' Apply a formula to G7 cell | |
_grid.Worksheets(0).Cells("G7").SetCellValue("=SUM(MyRange)") | |
' Calculate the results of the formulas | |
_grid.RunAllFormulas() | |
' Save the Excel file | |
_grid.ExportExcelFile(dataDir & "ouputBook1_out.xlsx") |
This file contains 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 Sub gridDesktop1_CellClick(sender As Object, e As Aspose.Cells.GridDesktop.CellEventArgs) | |
MessageBox.Show("Cell is clicked") | |
End Sub |
This file contains 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 | |
' | |
' gridDesktop1 | |
' | |
Me.gridDesktop1.ActiveSheetIndex = 0 | |
Me.gridDesktop1.ActiveSheetNameFont = Nothing | |
Me.gridDesktop1.CommentDisplayingFont = New System.Drawing.Font("Arial", 9F) | |
Me.gridDesktop1.Dock = System.Windows.Forms.DockStyle.Fill | |
Me.gridDesktop1.IsHorizontalScrollBarVisible = True | |
Me.gridDesktop1.IsVerticalScrollBarVisible = True | |
Me.gridDesktop1.Location = New System.Drawing.Point(0, 0) | |
Me.gridDesktop1.Name = "gridDesktop1" | |
Me.gridDesktop1.SheetNameFont = New System.Drawing.Font("Verdana", 8F) | |
Me.gridDesktop1.SheetTabWidth = 400 | |
Me.gridDesktop1.Size = New System.Drawing.Size(657, 452) | |
Me.gridDesktop1.TabIndex = 0 | |
AddHandler Me.gridDesktop1.CellClick, New Aspose.Cells.GridDesktop.CellEventHandler(AddressOf Me.gridDesktop1_CellClick) | |
' | |
' GridDesktopEvents | |
' |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Specifying the path of Excel file using ImportExcelFile method of the control | |
gridDesktop1.ImportExcelFile(dataDir & "SampleCSV1.csv") |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Specifying the path of Excel file using ImportExcelFile method of the control | |
gridDesktop1.ImportExcelFile(dataDir & "Sample.xlsx") |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Opening an Excel file as a stream | |
Dim fs As FileStream = File.OpenRead(dataDir & "Sample.xlsx") | |
' Loading the Excel file contents into the control from a stream | |
gridDesktop1.ImportExcelFile(fs) | |
' Closing stream | |
fs.Close() |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Saving Grid contents to an Excel file | |
gridDesktop1.ExportExcelFile(dataDir & "book1_out.xls") | |
' Saving Grid contents to MS Excel 2007 Xlsx file format | |
gridDesktop1.ExportExcelFile(Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) & "book1_out.xlsx", FileFormatType.Excel2007Xlsx) |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Opening an Excel file as a stream | |
Dim fs As FileStream = File.Open(dataDir & "book1_out.xls", FileMode.Open, FileAccess.ReadWrite) | |
' Saving Grid contents of the control to a stream | |
gridDesktop1.ExportExcelFile(fs) | |
' Closing stream | |
fs.Close() |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Adding checkbox to a specific column of the Worksheet | |
sheet.Columns(2).AddCheckBox() |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Creating an array of items or values that will be added to combobox | |
Dim items As String() = New String(2) {} | |
items(0) = "Aspose" | |
items(1) = "Aspose.Grid" | |
items(2) = "Aspose.Grid.Desktop" | |
' Adding combobox (containing items) to a specific column of the Worksheet | |
sheet.Columns(2).AddComboBox(items) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding column to the worksheet | |
sheet.AddColumn() |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Inserting column to the worksheet to the first position. | |
gridDesktop1.Worksheets(0).InsertColumn(0) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding row to the worksheet | |
sheet.AddRow() |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Inserting row to the worksheet to the first position. | |
gridDesktop1.Worksheets(0).InsertRow(0) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the first column of the worksheet | |
Dim column As Aspose.Cells.GridDesktop.Data.GridColumn = sheet.Columns(0) | |
' Adding sample value to sheet cell | |
Dim cell As GridCell = sheet.Cells("a1") | |
cell.SetCellValue("Aspose") | |
' Getting the Style object for the column | |
Dim style As Style = column.GetStyle() | |
' Setting Style properties i.e. border, alignment color etc. | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thick) | |
style.SetBorderColor(BorderType.Right, Color.Blue) | |
style.HAlignment = HorizontalAlignmentType.Centred | |
' Setting the style of the column with the customized Style object | |
column.SetStyle(style) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the first row of the worksheet | |
Dim row As Aspose.Cells.GridDesktop.Data.GridRow = sheet.Rows(0) | |
' Getting the Style object for the row | |
'Dim style As Style = row.GetStyle() | |
' Setting Style properties i.e. border, color, alignment, background color etc. | |
'style.SetBorderLine(BorderType.Right, BorderLineType.Thick) | |
'style.SetBorderColor(BorderType.Right, Color.Blue) | |
'style.HAlignment = HorizontalAlignmentType.Centred | |
'style.Color = Color.Yellow | |
' Setting the style of the row with the customized Style object | |
'row.SetStyle(style) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Setting the number of frozen columns to 2 | |
sheet.FrozenCols = 2 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Setting the number of frozen rows to 2 | |
sheet.FrozenRows = 2 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Setting the number of frozen columns to 0 for unfreezing columns | |
sheet.FrozenCols = 0 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Setting the number of frozen rows to 0 for unfreezing rows | |
sheet.FrozenRows = 0 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing cell control in the column and typecasting it to CheckBox | |
Dim cb As Aspose.Cells.GridDesktop.CheckBox = DirectCast(sheet.Columns(2).CellControl, Aspose.Cells.GridDesktop.CheckBox) | |
If cb IsNot Nothing Then | |
' Modifying the Checked property of CheckBox | |
cb.Checked = True | |
Else | |
MessageBox.Show("Please add control before accessing it.") | |
End If |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Removing cell control from the column | |
sheet.Columns(2).RemoveCellControl() |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Removing the first column of the worksheet | |
sheet.RemoveColumn(0) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Removing the first row of the worksheet | |
sheet.RemoveRow(0) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Adding sample value to sheet cell | |
Dim cell As GridCell = sheet.Cells("a1") | |
cell.SetCellValue("Welcome to Aspose!") | |
' Accessing the first column of the worksheet | |
Dim column As Aspose.Cells.GridDesktop.Data.GridColumn = sheet.Columns(0) | |
' Setting the width of the column | |
column.Width = 150 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Adding sample value to sheet cells | |
Dim cell As GridCell = sheet.Cells("b2") | |
cell.SetCellValue("1") | |
cell = sheet.Cells("c2") | |
cell.SetCellValue("2") | |
cell = sheet.Cells("d2") | |
cell.SetCellValue("3") | |
cell = sheet.Cells("e2") | |
cell.SetCellValue("4") | |
' Accessing the first row of the worksheet | |
Dim row As Aspose.Cells.GridDesktop.Data.GridRow = sheet.Rows(1) | |
' Setting the height of the row | |
row.Height = 100 |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing the Validation object applied on a specific column | |
'Validation validation = sheet.Columns[2].Validation; | |
' Editing the attributes of Validation | |
'validation.IsRequired = true; | |
'validation.RegEx = ""; | |
'validation.CustomValidation = null; |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding Is Required Validation to a column | |
sheet.Columns(2).AddValidation(True, "") | |
' Adding simple Regular Expression Validation to a column | |
sheet.Columns(4).AddValidation(True, "\d+") | |
' Adding complex Regular Expression Validation to a column | |
sheet.Columns(6).AddValidation(True, "\d{4}-\d{2}-\d{2}") | |
' Adding Custom Validation to a column | |
sheet.Columns(8).AddValidation(New CustomValidation()) |
This file contains 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 | |
' Implementing ICustomValidation interface | |
Public Class CustomValidation | |
Implements Aspose.Cells.GridDesktop.ICustomValidation | |
' Implementing Validate method already defined in the interface | |
Public Function Validate(worksheet As Worksheet, row As Integer, col As Integer, value As Object) As Boolean Implements ICustomValidation.Validate | |
' Checking the cell's address | |
If row = 7 AndAlso col = 0 Then | |
'Checking the data type of cell's value | |
Dim d As Double = 0 | |
Try | |
d = CDbl(value) | |
Catch | |
Return False | |
End Try | |
' Checking if the cell's value is greater than 100 | |
If d > 100 Then | |
Return True | |
End If | |
End If | |
Return False | |
End Function | |
End Class |
This file contains 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 first worksheet of the Grid | |
'Worksheet sheet = gridDesktop1.Worksheets[0]; | |
' Removing the Validation applied on a specific column | |
'sheet.Columns[2].RemoveValidation(); |
This file contains 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 | |
' Accesing an active worksheet using its index | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(gridDesktop1.ActiveSheetIndex) |
This file contains 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 | |
' Accesing an active worksheet directly | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() |
This file contains 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 | |
' Accesing a worksheet using its index | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) |
This file contains 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 | |
' Accesing a worksheet using its name | |
Dim sheet As Worksheet = gridDesktop1.Worksheets("Sheet2") |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the location of the cell that is currently in focus | |
Dim cl As CellLocation = sheet.GetFocusedCellLocation() | |
' Adding checkbox to the Controls collection of the Worksheet | |
sheet.Controls.AddCheckBox(cl.Row, cl.Column, True) |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Accessing the location of the cell that is currently in focus | |
Dim cl As CellLocation = sheet.GetFocusedCellLocation() | |
'Creating an array of items or values that will be added to combobox | |
Dim items As String() = New String(2) {} | |
items(0) = "Aspose" | |
items(1) = "Aspose.Grid" | |
items(2) = "Aspose.Grid.Desktop" | |
' Adding combobox to the Controls collection of the Worksheet | |
sheet.Controls.AddComboBox(cl.Row, cl.Column, items) |
This file contains 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 | |
' Implenting CellCheckedChanged event handler | |
Private Sub gridDesktop1_CellCheckedChanged(sender As Object, e As CellControlEventArgs) | |
' Getting the reference of the CheckBox control whose event is triggered | |
Dim check As Aspose.Cells.GridDesktop.CheckBox = DirectCast(gridDesktop1.GetActiveWorksheet().Controls(e.Row, e.Column), Aspose.Cells.GridDesktop.CheckBox) | |
' Displaying the message when the Checked state of CheckBox is changed | |
MessageBox.Show("Current state of CheckBox is " & check.Checked) | |
End Sub |
This file contains 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 | |
' Implenting CellSelectedIndexChanged event handler | |
Private Sub gridDesktop1_CellSelectedIndexChanged(sender As Object, e As CellComboBoxEventArgs) | |
' Getting the reference of the ComboBox control whose event is triggered | |
Dim combo As Aspose.Cells.GridDesktop.ComboBox = DirectCast(gridDesktop1.GetActiveWorksheet().Controls(e.Row, e.Column), Aspose.Cells.GridDesktop.ComboBox) | |
' Displaying the message when the Selected Index of ComboBox is changed | |
MessageBox.Show(combo.Items(combo.SelectedIndex).ToString()) | |
End Sub |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Set the image. | |
Dim image__1 As Image = Image.FromFile(dataDir & "AsposeLogo.jpg") | |
button.Image = image__1 |
This file contains 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 the Grid | |
Dim i As Integer = gridDesktop1.Worksheets.Add() | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(i) |
This file contains 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 the Grid with a specific name | |
Dim sheet1 As Worksheet = gridDesktop1.Worksheets.Add("AddWorksheetWithName") |
This file contains 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 a worksheet to Grid at first position of the worksheets collection | |
gridDesktop1.Worksheets.Insert(0) |
This file contains 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 a worksheet to Grid at first position with a specific sheet name | |
Dim sheet1 As Worksheet = gridDesktop1.Worksheets.Insert(0, "InsertWorksheetWithName") |
This file contains 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 | |
' Hiding the vertical scroll bar | |
gridDesktop1.IsVerticalScrollBarVisible = False | |
' Hiding the horizontal scroll bar | |
gridDesktop1.IsHorizontalScrollBarVisible = False |
This file contains 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 | |
' Displaying the vertical scroll bar | |
gridDesktop1.IsVerticalScrollBarVisible = True | |
' Displaying the horizontal scroll bar | |
gridDesktop1.IsHorizontalScrollBarVisible = True |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
'Getting the total number of rows and columns inside the worksheet | |
Dim totalRows As Integer = sheet.RowsCount | |
Dim totalCols As Integer = sheet.ColumnsCount | |
' Exporting the data of the active worksheet to a new DataTable object | |
Dim table As DataTable = sheet.ExportDataTable(0, 0, totalRows, totalCols, False, True) |
This file contains 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 | |
Dim dataTable As New DataTable() | |
' Adding specific columns to the DataTable object | |
dataTable.Columns.Add("ProductName", System.Type.[GetType]("System.String")) | |
dataTable.Columns.Add("CategoryName", System.Type.[GetType]("System.String")) | |
dataTable.Columns.Add("QuantityPerUnit", System.Type.[GetType]("System.String")) | |
dataTable.Columns.Add("UnitsInStock", System.Type.[GetType]("System.Int32")) | |
' Exporting the data of the first worksheet of the Grid to the specific DataTable object | |
dataTable = gridDesktop1.Worksheets(0).ExportDataTable(dataTable, 0, 0, 69, 4, True) |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
Dim adapter As OleDbDataAdapter | |
Dim dt As New DataTable() | |
' Creating connection string to connect with database | |
Dim conStr As String = "Provider=microsoft.jet.oledb.4.0;Data Source=" & dataDir & "dbDatabase.mdb" | |
' Creating Select query to fetch data from database | |
Dim query As String = "SELECT * FROM Products ORDER BY ProductID" | |
adapter = New OleDbDataAdapter(query, conStr) | |
' Filling DataTable using an already created OleDbDataAdapter object | |
adapter.Fill(dt) | |
' Accessing the reference of a worksheet | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Importing data from DataTable to the worksheet. 0,0 specifies to start importing data from the cell with first row (0 index) and first column (0 index) | |
sheet.ImportDataTable(dt, False, 0, 0) | |
' Iterating through the number of columns contained in the DataTable | |
For i As Integer = 0 To dt.Columns.Count - 1 | |
' Setting the column headers of the worksheet according to column names of the DataTable | |
sheet.Columns(i).Header = dt.Columns(i).Caption | |
Next | |
' Setting the widths of the columns of the worksheet | |
sheet.Columns(0).Width = 240 | |
sheet.Columns(1).Width = 160 | |
sheet.Columns(2).Width = 160 | |
sheet.Columns(3).Width = 100 | |
' Displaying the contents of the worksheet by making it active | |
gridDesktop1.ActiveSheetIndex = 0 |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Getting the location of the cell that is currently in focus | |
Dim cl As CellLocation = sheet.GetFocusedCellLocation() | |
' Accessing cell control and typecasting it to CheckBox | |
Dim cb As Aspose.Cells.GridDesktop.CheckBox = DirectCast(sheet.Controls(cl.Row, cl.Column), Aspose.Cells.GridDesktop.CheckBox) | |
If cb IsNot Nothing Then | |
' Modifying the Checked property of CheckBox | |
cb.Checked = True | |
Else | |
MessageBox.Show("Please add control before accessing it.") | |
End If |
This file contains 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 | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Getting the location of the cell that is currently in focus | |
Dim cl As CellLocation = sheet.GetFocusedCellLocation() | |
' Removing the cell control by specifying the location of cell containing it | |
sheet.Controls.Remove(cl.Row, cl.Column) |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing a comment added to "c3" cell (specified using its row & column number) | |
Dim comment1 As Aspose.Cells.GridDesktop.Data.GridComment = sheet.Comments(3, 1) | |
If comment1 IsNot Nothing Then | |
' Modifying the text of comment | |
comment1.Text = "The 1st comment." | |
MessageBox.Show("Comment has been modified") | |
Else | |
MessageBox.Show("Please add comment before accessing it.") | |
End If |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding comment to "b2" cell | |
sheet.Comments.Add("b2", "Please write your name.") | |
' Adding another comment to "b4" cell using its row & column number | |
sheet.Comments.Add(3, 1, "Please write your email.") |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
If sheet.Comments(3, 1) IsNot Nothing Then | |
' Removing comment from "c3" cell | |
sheet.Comments.Remove(3, 1) | |
MessageBox.Show("Comment has been removed") | |
Else | |
MessageBox.Show("Please add comment before removing it.") | |
End If |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing a hyperlink added to "c3,b2" cells (specified using its row & column number) | |
Dim hyperlink1 As Aspose.Cells.GridDesktop.Data.GridHyperlink = sheet.Hyperlinks(2, 2) | |
Dim hyperlink2 As Aspose.Cells.GridDesktop.Data.GridHyperlink = sheet.Hyperlinks(1, 1) | |
If hyperlink1 IsNot Nothing AndAlso hyperlink2 IsNot Nothing Then | |
' Modifying the Url of the hyperlink | |
hyperlink1.Url = "www.aspose.com" | |
hyperlink2.Url = "www.aspose.com" | |
MessageBox.Show("Hyperlinks are accessed and URL's are: " & vbLf & hyperlink1.Url & vbLf & hyperlink2.Url) | |
Else | |
MessageBox.Show("No hyperlinks are found in sheet. Add hyperlinks first.") | |
End If |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing cell of the worksheet | |
Dim cell As GridCell = sheet.Cells("b2") | |
Dim cell2 As GridCell = sheet.Cells("c3") | |
' Modifying the width of the column of the cell | |
sheet.Columns(cell.Column).Width = 160 | |
sheet.Columns(cell2.Column).Width = 160 | |
' Adding a value to the cell | |
cell.Value = "Aspose Home" | |
cell2.Value = "Aspose Home" | |
' Adding a hyperlink to the worksheet containing cell name and the hyperlink URL with which the cell will be linked | |
sheet.Hyperlinks.Add("b2", "www.aspose.com") | |
sheet.Hyperlinks.Add("c3", "www.aspose.com") |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
If sheet.Hyperlinks.Count > 0 Then | |
' Removing hyperlink from "c3" cell | |
sheet.Hyperlinks.Remove(2, 2) | |
MessageBox.Show("Hyperlink in C3 cell has been removed.") | |
Else | |
MessageBox.Show("No hyperlinks are found in sheet to remove. Add hyperlinks first.") | |
End If |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Accessing first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Accessing a picture added to "c3" cell (specified using its row & column number) | |
Dim picture1 As Aspose.Cells.GridDesktop.Data.GridPicture = sheet.Pictures(1) | |
' Modifying the image | |
picture1.Image = Image.FromFile(dataDir & "Aspose.Grid.jpg") |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Accessing first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding picture to "b2" cell from file | |
sheet.Pictures.Add("b2", dataDir & "AsposeGrid.jpg") | |
' Creating a stream contain picture | |
Dim fs As New FileStream(dataDir & "AsposeLogo.jpg", FileMode.Open) | |
Try | |
' Adding picture to "b3" cell from stream | |
sheet.Pictures.Add(2, 1, fs) | |
Catch ex As Exception | |
MessageBox.Show(ex.Message) | |
Finally | |
' Closing stream | |
fs.Close() | |
End Try |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Removing picture from "c3" cell | |
sheet.Pictures.Remove(2, 2) |
This file contains 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 | |
' Move the 2nd worksheet to 4th position. | |
gridDesktop1.Worksheets.MoveTo(1, 3) |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Import sample excel file in GridDesktop | |
gridDesktop1.ImportExcelFile(dataDir & "ValidationTesting.xlsx") |
This file contains 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 index | |
gridDesktop1.Worksheets.Remove(0) |
This file contains 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 index | |
gridDesktop1.Worksheets.RemoveAt("Sheet3") |
This file contains 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 | |
' Accesing an active worksheet directly | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Renaming a worksheet | |
sheet.Name = "Renamed Sheet" |
This file contains 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 that is currently active | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Creating SortRange object | |
Dim sr As New SortRange(sheet, range.StartRow, range.StartColumn, range.EndRow - range.StartRow + 1, range.EndColumn - range.StartColumn + 1, SortOrientation.SortTopToBottom, _ | |
True) | |
' Sorting data in the specified column in ascending order | |
sr.Sort(range.StartColumn, Aspose.Cells.GridDesktop.SortOrder.Ascending) | |
' Redrawing cells of the Grid | |
gridDesktop1.Invalidate() |
This file contains 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 global variable of CellRange | |
Private range As CellRange | |
Private Sub gridDesktop1_SelectedCellRangeChanged(sender As Object, e As Aspose.Cells.GridDesktop.CellRangeEventArgs) | |
' Checking if the range of cells is not empty | |
If (e.CellRange.EndColumn - e.CellRange.StartColumn > 0) OrElse (e.CellRange.EndRow - e.CellRange.StartRow > 0) Then | |
' Assigning the updated CellRange to global variable | |
range = e.CellRange | |
End If | |
End Sub |
This file contains 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 that is currently active | |
Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() | |
' Creating SortRange object | |
Dim sr As New SortRange(sheet, range.StartRow, range.StartColumn, range.EndRow - range.StartRow + 1, range.EndColumn - range.StartColumn + 1, SortOrientation.SortTopToBottom, _ | |
True) | |
' Sorting data in the specified column in descending order | |
sr.Sort(range.StartColumn, Aspose.Cells.GridDesktop.SortOrder.Descending) | |
' Redrawing cells of the Grid | |
gridDesktop1.Invalidate() |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
If sheet.Validations.Count > 0 Then | |
' Accessing the Validation object applied on "a8" cell | |
Dim validation As Aspose.Cells.GridDesktop.Data.GridValidation = sheet.Validations(7, 0) | |
' Editing the attributes of Validation | |
validation.IsRequired = True | |
validation.RegEx = "" | |
validation.CustomValidation = Nothing | |
MessageBox.Show("Validation has been edited after accessing it.") | |
Else | |
MessageBox.Show("No validations found to access.") | |
End If |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
' Adding values to specific cells of the worksheet | |
sheet.Cells("a2").Value = "Required" | |
sheet.Cells("a4").Value = "100" | |
sheet.Cells("a6").Value = "2006-07-21" | |
sheet.Cells("a8").Value = "101.2" | |
' Adding Is Required Validation to a cell | |
sheet.Validations.Add("a2", True, "") | |
' Adding simple Regular Expression Validation to a cell | |
sheet.Validations.Add("a4", True, "\d+") | |
' Adding complex Regular Expression Validation to a cell | |
sheet.Validations.Add("a6", True, "\d{4}-\d{2}-\d{2}") | |
' Adding Custom Validation to a cell | |
sheet.Validations.Add("a8", New CustomValidation()) |
This file contains 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 | |
' Implementing ICustomValidation interface | |
Public Class CustomValidation | |
Implements Aspose.Cells.GridDesktop.ICustomValidation | |
' Implementing Validate method already defined in the interface | |
Public Function Validate(worksheet As Worksheet, row As Integer, col As Integer, value As Object) As Boolean Implements ICustomValidation.Validate | |
' Checking the cell's address | |
If row = 7 AndAlso col = 0 Then | |
'Checking the data type of cell's value | |
Dim d As Double = 0 | |
Try | |
d = CDbl(value) | |
Catch | |
Return False | |
End Try | |
' Checking if the cell's value is greater than 100 | |
If d > 100 Then | |
Return True | |
End If | |
End If | |
Return False | |
End Function | |
End Class |
This file contains 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 first worksheet of the Grid | |
Dim sheet As Worksheet = gridDesktop1.Worksheets(0) | |
If sheet.Validations.Count > 0 Then | |
' Removing the Validation object applied on "a6" cell | |
sheet.Validations.RemoveAt(1) | |
MessageBox.Show("Validation has been removed.") | |
Else | |
MessageBox.Show("No validations found to remove.") | |
End If |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
' Importing the template Excel file to GridDesktop | |
gridDesktop1.ImportExcelFile(dataDir & "EmployeeSales.xlsx") | |
' Set the default value of the TrackBar control | |
trackBar1.Value = 100 | |
' Set the custom label's text to the trackbar's value for display | |
label1.Text = trackBar1.Value.ToString() & "%" |
This file contains 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 | |
' Set the Zoom factor of the active worksheet to the Trackbar's value | |
gridDesktop1.Worksheets(gridDesktop1.GetActiveWorksheet().Index).Zoom = trackBar1.Value | |
' Show the percentage value of the specified Zoom | |
label1.Text = trackBar1.Value.ToString() & "%" |
This file contains 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 | |
' The path to the documents directory. | |
Dim dataDir As String = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) | |
Using stream = New MemoryStream(File.ReadAllBytes(dataDir & Convert.ToString("SampleBook.xlsx"))) | |
Me.grid.ImportExcelFile(stream) | |
Me.grid.ExportExcelFile(dataDir & Convert.ToString("SampleOutput_out.xlsx")) | |
End Using |
This file contains 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 | |
// Enable GridDesktop's auto-filter. | |
gridDesktop1.Worksheets[0].RowFilter.EnableAutoFilter = true; | |
// Set the header row. | |
gridDesktop1.Worksheets[0].RowFilter.HeaderRow = 0; | |
gridDesktop1.Worksheets[0].RefreshFilter(); |
This file contains 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 | |
// Set the header row. | |
gridDesktop1.Worksheets[0].RowFilter.HeaderRow = 0; | |
// Get the RowFilter object for the first worksheet. | |
RowFilterSettings rowFilter = gridDesktop1.Worksheets[0].RowFilter; | |
// Filter Rows. | |
rowFilter.FilterRows(0, "Customer 1"); | |
gridDesktop1.Worksheets[0].RefreshFilter(); |
This file contains 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 RowFilter object for the first worksheet. | |
RowFilterSettings rowFilter = gridDesktop1.Worksheets[0].RowFilter; | |
// Filter Rows. | |
rowFilter.CustomRows(0, GridFilterOperatorType.NotEqual, "Customer 1"); | |
gridDesktop1.Worksheets[0].RefreshFilter(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment