Addressing Cells on another Worksheet

Will Aspose.Excel allow Worksheet1 to address cells on Worksheet2? Are these addresses
preserved when generating the spreadsheet for download? OWC10 (per documentation), converts these addresses to hard values, so we need a solution.

Will Aspose.Excel do this?


Dear Dale,

Thanks for your consideration.

Yes Aspose.Excel can help you do that.

For example, the following code illustrates cell A1 of Sheet1 will change when cell C3 of Sheet2 changes:

[C#]
Worksheet sheet1 = excel.Worksheets.GetAt(0);
Worksheet sheet2 = excel.Worksheets.GetAt(1);
sheet2.Name = “SecondSheet”;

Cell cell = sheet1.Cells.GetAt(“A1”);
cell.Formula = “=SecondSheet!C3”;

[Visual Basic]
Dim sheet1 As Worksheet = excel.Worksheets.GetAt(0)
Dim sheet2 As Worksheet = excel.Worksheets.GetAt(1)
sheet2.Name = “SecondSheet”

Dim cell As Cell = sheet1.Cells.GetAt(“A1”)
cell.Formula = “=SecondSheet!C3”

Perfect! Thanks for the code sample, your reply is right on time!

Hi,

Thanks for using Aspose.Cells.

Aspose.Excel is quite an old version. Now it has been renamed as Aspose.Cells and there are lots of major changes and improvements.

In order to get familiar with the latest Aspose.Cells quickly, please download and try the latest offline demos.

These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.



The above code will now look like this.

C#

Worksheet sheet1 = workbook.Worksheets[0];

Worksheet sheet2 = workbook.Worksheets[1];

sheet2.Name = “SecondSheet”;


Cell cell = sheet1.Cells[“A1”];

cell.Formula = “=SecondSheet!C3”;



Visual Basic
Dim sheet1 As Worksheet = workbook.Worksheets(0)
Dim sheet2 As Worksheet = workbook.Worksheets(1)
sheet2.Name = "SecondSheet"

Dim cell As Cell = sheet1.Cells("A1")
cell.Formula = "=SecondSheet!C3"