Hi!
I am using a template xls which i open , put some values and then save it with some other name. I have defined some named ranges in that template xls and i want that by code i could just replace the values of those ranges by using there names rather than specifying the exact cell index. can you please help me in that by giving some code snippet specifying how can i access those named ranges and replace there values.
Thanks
Ankur
hi!
I would also like to know that how can i remove the rows for those named ranges and shift the cells up.
Thanks,
Ankur
Dear Ankur,
Please use Worksheets.GetRangeByName method to access named ranges and use Cells.DeleteRange method to remove rows.
@ankur.sharda,
Aspose.Excel is discarded now and no more available now. A new product Aspose.Cells has replaced it which has much more advanced features for working with ranges. You can not only access ranges by names but also perform many tasks like search and replace data in a range, copy range data with styles, convert Excel table to range and formatting a range of cells. Here is an example that demonstrates accessing the ranges by name.
// Instantiate a new Workbook.
Workbook workbook = new Workbook(dataDir + "book1.xls");
// Getting the specified named range
Range range = workbook.Worksheets.GetRangeByName("TestRange");
// Identify range cells.
Console.WriteLine( "First Row : " + range.FirstRow);
Console.WriteLine( "First Column : " + range.FirstColumn);
Console.WriteLine( "Row Count : " + range.RowCount);
Console.WriteLine( "Column Count : " + range.ColumnCount);
Refer to the following articles for working with ranges:
Create Access and Copy Named Ranges
Formatting a Range of Cells
Tables and Ranges
Copy Range Data with Style
Search and Replace Data in a Range
Download the free trial version here:
Aspose.Cells for .NET(Latest version)
Here is a runnable complete solution which contains lot of examples to test different features of Aspose.Cells.