Spreadsheets and Excel

Using ES3Spreadsheet, Easy Save has the ability to create spreadsheets and store them in the CSV format which is supported by all popular spreadsheet software included Excel, OSX Numbers and OpenOffice.

To create a spreadsheet, you can do the following:

  1. Create an ES3Spreadsheet object.
  2. Use SetCell to set the value of a cell.
    • Note that columns and row numbers start at 0.
    • If the value isn’t a primitive type, the value will be converted to JSON.
  3. Use Save to store the spreadsheet to a file.
var sheet = new ES3Spreadsheet();

// Add data to cells in the spreadsheet.
for(int col=0; col<10; col++)
    for(int row=0; row<8; row++)
        sheet.SetCell(col, row, "someData");

sheet.Save("mySheet.csv");

If you want to append data to an existing spreadsheet, set the append parameter to true when calling Save(). Any rows in the spreadsheet will be added to the end of the one we’re saving to.

To load a spreadsheet:

  1. Create an ES3Spreadsheet object to load the data into.
  2. Use Load to load the spreadsheet from a CSV file.
// Create a blank ES3Spreadsheet.
var sheet = new ES3Spreadsheet();

sheet.Load("spreadsheet.csv");

// Output the first row of the spreadsheet to console.
for(int col=0; col<sheet.ColumnCount; col++)
    Debug.Log(sheet.GetCell<int>(col, 0));

Currently ES3Spreadsheet is unable to do the following, but may have these implemented in the future:

  • Save formulas.
  • Store formatting or styling information.
  • Save multiple worksheets.