SpreadJS provides camera shape.
You can add a camera shape and change the camera shape style using the CameraShape API
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import './styles.css';
import { AppFunc } from './app-func';
// import { App } from './app-class';
// 1. Functional Component sample
ReactDOM.render(<AppFunc />, document.getElementById('app'));
// 2. Class Component sample
// ReactDOM.render(<App />, document.getElementById('app'));
import * as React from 'react';
import GC from '@mescius/spread-sheets';
import { SpreadSheets, Worksheet } from '@mescius/spread-sheets-react';
import "@mescius/spread-sheets-shapes";
const Component = React.Component;
function prepareCellRangeData(sheet){
sheet.setArray(0, 0, [
["Product", "Price", "Quantity", "Sales"],
['Kraft Real Mayo', 5.71, 1],
['Smartfood Popcorn', 2.5, 4],
['Teddy Grahams Crackers', 35, 5],
['Parmesan Cheese', 14.89, 9],
['Planter Deluxe Whole Cashew', 8.52, 3],
['Total']
]);
sheet.setColumnWidth(0, 190);
sheet.setColumnWidth(1, 100);
sheet.setColumnWidth(2, 100);
sheet.setColumnWidth(3, 100);
sheet.setFormula(1, 3, "B2*C2");
sheet.setFormula(2, 3, "B3*C3");
sheet.setFormula(3, 3, "B4*C4");
sheet.setFormula(4, 3, "B5*C5");
sheet.setFormula(5, 3, "B6*C6");
sheet.addCustomName('customName1', '=$B$2:$B$6', 0, 0);
sheet.addCustomName('customName2', '=$C$2:$C$6', 0, 0);
sheet.setFormula(6, 1, "=SUM(customName1)");
sheet.setFormula(6, 2, "=SUM(customName2)");
sheet.getRange(6, 0, 1, 4).foreColor('red');
sheet.setFormula(6, 3, "B7*C7");
sheet.getRange(-1,1,0,1).formatter("$ #,##0.00");
sheet.getRange(-1,3,0,1).formatter("$ #,##0.00");
var table = sheet.tables.add("table1", 0, 0, 7, 4, GC.Spread.Sheets.Tables.TableThemes.light7);
table.filterButtonVisible(false);
}
function initShape(sheet) {
var shape = sheet.shapes.addCameraShape("myCameraShape1", "CameraShape!A1:D7", 240, 200);
var shapeStyle = shape.style();
shapeStyle.fill.color = 'pink';
shapeStyle.fill.transparency = 0.8;
shapeStyle.line.color = 'black';
shapeStyle.line.lineStyle = GC.Spread.Sheets.Shapes.PresetLineDashStyle.dashDot;
shapeStyle.line.width = 4;
shapeStyle.line.capType = GC.Spread.Sheets.Shapes.LineCapStyle.square;
shapeStyle.line.joinType = GC.Spread.Sheets.Shapes.LineJoinStyle.miter;
shapeStyle.line.transparency = 0.1;
shape.style(shapeStyle);
}
export function AppFunc() {
const initSpread = (spread) => {
let sheet = spread.getSheet(0);
prepareCellRangeData(sheet);
initShape(sheet);
};
return (<div class="sample-tutorial">
<div class="sample-spreadsheets">
<SpreadSheets workbookInitialized={spread => initSpread(spread)}>
<Worksheet name={"CameraShape"}></Worksheet >
</SpreadSheets>
</div>
</div>);
}
import * as React from 'react';
import GC from '@mescius/spread-sheets';
import { SpreadSheets, Worksheet } from '@mescius/spread-sheets-react';
import "@mescius/spread-sheets-shapes";
const Component = React.Component;
function prepareCellRangeData(sheet){
sheet.setArray(0, 0, [
["Product", "Price", "Quantity", "Sales"],
['Kraft Real Mayo', 5.71, 1],
['Smartfood Popcorn', 2.5, 4],
['Teddy Grahams Crackers', 35, 5],
['Parmesan Cheese', 14.89, 9],
['Planter Deluxe Whole Cashew', 8.52, 3],
['Total']
]);
sheet.setColumnWidth(0, 190);
sheet.setColumnWidth(1, 100);
sheet.setColumnWidth(2, 100);
sheet.setColumnWidth(3, 100);
sheet.setFormula(1, 3, "B2*C2");
sheet.setFormula(2, 3, "B3*C3");
sheet.setFormula(3, 3, "B4*C4");
sheet.setFormula(4, 3, "B5*C5");
sheet.setFormula(5, 3, "B6*C6");
sheet.addCustomName('customName1', '=$B$2:$B$6', 0, 0);
sheet.addCustomName('customName2', '=$C$2:$C$6', 0, 0);
sheet.setFormula(6, 1, "=SUM(customName1)");
sheet.setFormula(6, 2, "=SUM(customName2)");
sheet.getRange(6, 0, 1, 4).foreColor('red');
sheet.setFormula(6, 3, "B7*C7");
sheet.getRange(-1,1,0,1).formatter("$ #,##0.00");
sheet.getRange(-1,3,0,1).formatter("$ #,##0.00");
var table = sheet.tables.add("table1", 0, 0, 7, 4, GC.Spread.Sheets.Tables.TableThemes.light7);
table.filterButtonVisible(false);
}
function initShape(sheet) {
var shape = sheet.shapes.addCameraShape("myCameraShape1", "CameraShape!A1:D7", 240, 200);
var shapeStyle = shape.style();
shapeStyle.fill.color = 'pink';
shapeStyle.fill.transparency = 0.8;
shapeStyle.line.color = 'black';
shapeStyle.line.lineStyle = GC.Spread.Sheets.Shapes.PresetLineDashStyle.dashDot;
shapeStyle.line.width = 4;
shapeStyle.line.capType = GC.Spread.Sheets.Shapes.LineCapStyle.square;
shapeStyle.line.joinType = GC.Spread.Sheets.Shapes.LineJoinStyle.miter;
shapeStyle.line.transparency = 0.1;
shape.style(shapeStyle);
}
export class App extends Component {
constructor(props) {
super(props);
this.spread = null;
}
render() {
return (<div class="sample-tutorial">
<div class="sample-spreadsheets">
<SpreadSheets workbookInitialized={spread => this.initSpread(spread)}>
<Worksheet name={"CameraShape"}></Worksheet >
</SpreadSheets>
</div>
</div>);
}
initSpread(spread) {
let sheet = spread.getSheet(0);
prepareCellRangeData(sheet);
initShape(sheet);
}
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/react/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<!-- SystemJS -->
<script src="$DEMOROOT$/en/react/node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('$DEMOROOT$/en/lib/react/license.js').then(function () {
System.import('./src/app');
});
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: 100%;
height: 100%;
overflow: hidden;
float: left;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#app {
height: 100%;
}
(function (global) {
System.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true,
react: true
},
meta: {
'*.css': { loader: 'css' }
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js',
'@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js',
'@mescius/spread-sheets-react': 'npm:@mescius/spread-sheets-react/index.js',
'@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js',
'react': 'npm:react/umd/react.production.min.js',
'react-dom': 'npm:react-dom/umd/react-dom.production.min.js',
'css': 'npm:systemjs-plugin-css/css.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build':'npm:systemjs-plugin-babel/systemjs-babel-browser.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'jsx'
},
"node_modules": {
defaultExtension: 'js'
},
}
});
})(this);