Free Support Forum -

Aspose cells gridweb use of code

Hi Aspose Team,

Can you tell me what is the use of following line of code: GridWeb1.SelectCells ?


Well, GridWeb.SelectCells is used to retrieve the selected cells in the worksheet, see the example code below:

Sample code:


//I placed an ASP.NET button named Button1. In Page_Load event, I placed a simple code segment. I imported a simple file and then did sink events for the button's click.

protected void Page_Load(object sender, EventArgs e)
//if first visit this page clear GridWeb1
if (!IsPostBack)
Button1.Attributes["onclick"] = "GridWeb1.updateData(); return GridWeb1.validateAll();";

protected void Button1_Click(object sender, EventArgs e)
if (GridWeb1.SelectCells != null && GridWeb1.SelectCells.Count > 0)
int sRow = ((WebCell)((ArrayList)GridWeb1.SelectCells[0])[0]).Row;
int sCol = ((WebCell)((ArrayList)GridWeb1.SelectCells[0])[0]).Column;
int eRow = ((WebCell)((ArrayList)GridWeb1.SelectCells[GridWeb1.SelectCells.Count - 1])[0]).Row;
int eCol = ((WebCell)((ArrayList)GridWeb1.SelectCells[0])[GridWeb1.SelectCells.Count - 1]).Column;

for (int i = sRow; i <= eRow; i++)
for (int j = sCol; j <= eCol; j++)
Response.Write("Cell: " + GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex].Cells[i, j].Name + " Value: " + GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex].Cells[i, j].StringValue);


Hope, this helps.

Thank you.