Exporting to Spreadsheet and Excel
Using ES2Spreadsheet, 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.
Using ES2Spreadsheet
To create a spreadsheet, you do the following:
- Create an ES2Spreadsheet object.
- Use SetCell to set the value of a cell.
- Note that columns and row numbers start at 0.
- If the value isn’t a string, it will use ToString() on the value to get a string representation of it.
- Use Save to store the spreadsheet to a file.
C#
1 2 3 4 5 6 |
ES2Spreadsheet sheet = new ES2Spreadsheet(); // 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"); |
JS
1 2 3 4 5 6 |
var sheet : ES2Spreadsheet = new ES2Spreadsheet(); // Add data to cells in the spreadsheet. for(var col=0; col<10; col++) for(var row=0; row<8; row++) sheet.SetCell(col, row, "someData"); sheet.Save("mySheet.csv"); |
Appending rows to a spreadsheet
If you want to append data to an existing spreadsheet, set the spreadsheet’s append variable to true. Any rows in the spreadsheet will be added to the end of the one we’re saving to.
Limitations
Currently ES2Spreadsheet is unable to do the following, but may have these implemented in the future:
- Save formulas.
- Store formatting or styling information.
- Save multiple worksheets.