How do I use CellRange in Cells for .Net?

I am evaluating the .Net version of Cells and am trying to use the CellRange class as outlined in the online documentation for .Net. - in section "Formatting a Range of Cells".

My C# project does not recogize CellRange and asks if I have a missing using directive or assembly reference.

Any suggestions?

Thanks

Jim

Hi,

CellRange class belongs to Aspose.Cells for GridDesktop.

Since, you are using Aspose.Cells for .NET and not the Aspose.Cells for GridDesktop, so please see how to create a range of all the cells in
your desired worksheet and then apply a style.

Please see the source.xls files, I
have applied a style having background color with a number pattern to
all the cells. Please see the output file and screenshot.

I have used the latest version:
Aspose.Cells for .NET v7.1.2.6

C#


string path = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(path);

Worksheet worksheet = workbook.Worksheets[0];


string lastCell = worksheet.Cells.LastCell.Name;


Range rng = worksheet.Cells.CreateRange(“A1:” + lastCell);


Style st = workbook.CreateStyle();

//set the number pattern

st.Number = 2;


//set the background color to yellow

st.Pattern = BackgroundType.Solid;

st.ForegroundColor = Color.Yellow;


StyleFlag flag = new StyleFlag();

flag.All = true;


rng.ApplyStyle(st, flag);


workbook.Save(path + “.out.xlsx”);


Screenshot:

Thanks you. The CreateRange worked fine.
You might want to update your online .Net documentation since that led me to believe I should be using CellRange.

Again, thanks.

Jim

Hi,

It’s good to know, your problem is resolved and thanks for your feedback.

For your more help, please follow these links to get more familiar with Aspose.Cells


All these resources are also available in VB.NET.

Hi,


I would like to add more for your knowledge. The CellRange is an API of GridDesktop control and not the Aspose.Cells component, please see the root node i.e. Aspose.Cells.GridDesktop. For your information, Aspose.Cells for .NET has the following three products/component:
1) Aspose.Cells - the main library for all kinds of MS Excel file management or manipulation, it includes almost all the features that MS Excel 2003 -2010 support.

2) Aspose.Cells.GridDesktop - a windows based grid control used to load or manipulate Excel files, it provides Excel Grid like UI and you may use it in WYSIWYG (visual) manner.

3) Aspose.Cells.GridWeb - an ASP.NET/web based grid control used to load or manipulate Excel files, it provides Excel Grid like UI and you may use it in WYSIWYG (visual) manner.

Please see the product overview page for Aspose.Cells for .NET: