Cell Class

Provides access to a single cell in a worksheet.

Namespace: SpreadsheetCloudAPI.SpreadsheetSDK
Assembly: SpreadsheetSDK.dll

Syntax

C#
VB
public class Cell: object

Remarks

Cells are constituent elements of a worksheet. Each cell holds a single piece of worksheet data - the cell value. To access a cell value, use the Value property.

A cell can also contain a formula that calculates the cell value dynamically. To specify a cell formula, use the Formula property.

You can format cells to improve the worksheet appearance. To specify the desired style for a cell (text alignment, font attributes, format string, etc.), use the Style property.

You can merge or unmerge desired cells. For this purpose, use the Merge and Unmerge methods, respectively.

To access a cell's parent objects, such as a worksheet or a document, use the Worksheet and Document properties.

Example

This example demonstrates how to use SpreadsheetCloudAPI service to access located cloud files.

  • To access the files that belong to an application, first initialize the SpreadsheetSDK.dll using the API Key generated for your application. For this purpose, call the SpreadsheetSDK.Initialize method with your API Key as a parameter.

  • To create a new file and store it on the server, call the Document.Create method.

    To open an existing file stored on the server, call the Document.Load method.

  • To access a document's worksheet, use the Worksheet class and its members.

  • To access a worksheet's cells, use the Cell class and its members.

Note

It is important to terminate the session at the end of your code. For this purpose, call the Document.Close method each time you finish work with the document.

C#
using System;
using System.Collections.Generic;
using SpreadsheetSDK;

namespace SpreadsheetExample {
    class Program {
        static void Main() {
                    
            // SDK initialization
            SpreadsheetSDK.Initialize("SPECIFY_YOUR_API_KEY_HERE"); 
                    
            // Access the document that has been uploaded to the server
            Document doc = Document.Load("MyApplicationFile", "xlsx");
           
            // Access the worksheet
            List<Worksheet> worksheets = doc.Worksheets;
            Worksheet worksheet = worksheets[0];
                    
            // Access cells
            Cell cell1 = worksheet[0, 0];
            Cell cell2 = worksheet[0, 1];
            Cell cell3 = worksheet[1, 0];
                    
            // Specify formula
            cell3.Formula = "=A1*B1";
                
            // Set and get cell values
            cell1.Value = 5;
            cell2.Value = 10;
            var value = cell3.Value;
            Console.WriteLine("Value is {0}", value);
                    
            // Close the document and save changes
            doc.Close(true);
            Console.ReadKey();
        }
    }
}

Inheritance Hierarchy

System.Object
    Cell

See Also