Lesson 2 - Accessing Cloud Files

This document covers the second step of the Getting Started tutorial, and describes how to work with the SpreadsheetCloudAPI server from your code using Spreadsheet SDK. For detailed instructions on how to "bind" your application to the server, refer to Lesson 1.

First of all, let's upload a file to the application created in Lesson 1 using the file manager on the right of the SpreadsheetCloudAPI web interface. For this purpose, click Upload and select an existing file using the Open File dialog. The supported file extensions are: OPENXML (XLSX), XLS and CSV.

Note

The maximum file size is limited by 10MB. The maximum storage size (all files for all applications per one account) is limited by 100 MB.

As an alternative, click Create empty file, specify required file credentials (name and extension) and click Create in the subsequent dialog. The created file will be added to the currently-selected application.

Now, follow the steps below to access and modify the uploaded file directly from your application's code.

  1. Open your application's code in Microsoft Visual Studio.

  2. Select Tools | NuGet Package Manager | Package Manager Console from the Visual Studio main menu.

  3. Execute the command below.

    Install-Package SpreadsheetSDK
  4. Initialize SpreadsheetSDK.dll from your application's code using the API Key generated in the Lesson 1. The initialization code must be specified once, once your application is loaded.

    C#
    using SpreadsheetSDK;
    ...
    SpreadsheetSDK.Initialize("SPECIFY_YOUR_API_KEY_HERE");
  5. Use SpreadsheetSDK's API to communicate with the document stored on the SpreadsheetCloudAPI server. The sample console application below shows how to use SpreadsheetSDK for setting cell values and specifying formulas.

    C#
    // Access the document 
    Document doc = Document.Load("MyApplicationFile", "xlsx");
    
    // Access the worksheet 
    List<Worksheet> worksheets = (List<Worksheet>)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();
    

For more information on Spreadsheet SDK, see the SpreadsheetSDK section.