npm install sprd
or
- Keyboard navigation using arrow keys or page up and page down
- Copy and Paste
- Infinite scrolling vertically and horizontally
- Custom cell formatting
- Drag highlighting
import {SprdContainer} from 'sprd';
let data = [
['Name', 'Age'],
['sam', 20],
['Mike', 30],
['Greg', 40],
['Monroe', 50],
['sam', 20],
['Mike', 30],
['Greg', 40],
['Monroe', 50],
['sam', 20],
['Mike', 30],
];
<SprdContainer
width={800}
height={600}
data={data}/>
import {SprdContainer} from 'sprd';
<SprdContainer
width={800}
height={600}
onEvent={(eventType, range, data) => {
console.log(eventType, range, data)
if(range) console.log(range.getAddress())
}}
data={data}/>
import {SprdContainer} from 'sprd';
<SprdContainer
width={800}
height={600}
cellOverride={(cellInfo, innerCell, outerCell) => {
if(cellInfo.row === 0){
innerCell = (
<select {...innerCell.props} style={{padding: 3}} ref={innerCell.ref}>
<option>Hello</option>
<option>World</option>
</select>
)
}
if(cellInfo.row === 0){
outerCell = <span {...outerCell.props} style={{fontWeight: 'bold'}}/>
}
if(cellInfo.row > 5 && cellInfo.row < 10){
outerCell = <span {...outerCell.props} style={{color: 'green'}}/>
}
if(cellInfo.dataType === "number"){
outerCell = <span {...outerCell.props} style={{color: 'blue', fontSize: 11}} key={outerCell.key}/>
}
return {innerCell, outerCell}}
}
data={data}/>
import {Store} from 'sprd';
console.log(Store.getData());
This will return a json object with the top level keys corresponding to the row indices and the keys in the nested json objects corresponding to column indices e.g
{
0:{0: "Name", 1: "Age"},
1:{0: "sam", 1: 20},
2:{0: "Mike", 1: 30},
3:{0: "Greg", 1: 40}
}
NB: Any cells without data are not captured
showHeaderLetters
- whether to show the excel like header letters at the top of columns, default is trueshowFooter
- whether to show the footer that displays the cell address, default is trueinfiniteScroll
- whether to scroll infinitely both vertically and horizontally, default is truewidth
- the width in pixels of the grid, default is 1000height
- the height in pixels of the grid, default is 800onEvent
- javascript function to listen to events in the spreadsheetcolumnDataTypes
- an array containing the list of column data typescellOverride
- a callback to override default cells with your own custom cellsdata
- an array of arrays containing the default data