• Home
  • Tools
  • How To Set Cell Value in SpreadJS

How To Set Cell Value in SpreadJS

eric pengviaWijmo
May 13, 2013

SpreadJS provides many ways to assign value to cells, you can choose any one of options below to set value of cells.

1. setValue/setText method

Sheet object of SpreadJS has a method setValue, this method can be used to set value to any cell in viewport or headers by specific row and column index. The value can be any type of data like string, date time, boolean, number. In addition, the Sheet object has another method setText, you can use this method to set text to any cell in either viewport or header.

sheet.setValue(0,2,"ColumnHeader", $.wijmo.wijspread.SheetArea.colHeader);
sheet.setValue(2,0,"RowHeader", $.wijmo.wijspread.SheetArea.rowHeader);
sheet.setValue(2,2,"viewport", $.wijmo.wijspread.SheetArea.viewport);

2. Set value by Cell object

Sheet object has two methods getCell and getCells, you can use them to get a Cell object which indicates a specific cell, or a range of cells, and use value/text method of Cell object to set value to a cell or a range of cells.


3. Binding to JSon array

You can create a JSON array, and bind it to Sheet object by using the setDataSource method.

var arr = [

4. Import CSV text

You can import a CSV text string into a range of cells by using the setCsv method of Sheet object.

var csv = "1,2,3;a,b,c";

You can try all of the above code in a web page which has initialized SpreadJS, to learn more about getting started with SpreadJS in a web page, please read Quick Start Guide to Using SpreadJS.

For more information about how to use SpreadJS, includes its data model and API, please read our online documentation or try online demos.