データオブジェクト型セル

データオブジェクト型セルは、オブジェクト型のカスタムデータを使用するためのより便利な方法を提供します。

データオブジェクトのセル型は、1つのパラメータformatを、PROPERTY関数またはドット演算子を含むフォーマット文字列として受け取ります。 これは、オブジェクト型のセルの値を、文字列としてどのように表示するか決定します。 これはクラスの定義です。 これはサンプルコードです。
/*REPLACE_MARKER*/ /*DO NOT DELETE THESE COMMENTS*/ window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); initSpread(spread); }; function initSpread(spread) { spread.suspendPaint(); var sheet = spread.getActiveSheet(); sheet.setColumnWidth(1, 500); //set a DataObject celltype which uses WEBSERVICE function to provide data sheet.setFormula(1, 1, '=FILTERJSON(WEBSERVICE("https://demodata.mescius.io/northwind/api/v1/Products/1"))'); var cellType1 = new GC.Spread.Sheets.CellTypes.DataObject('=@.productName & " " & @.unitPrice'); sheet.setCellType(1, 1, cellType1); var baseApiUrl = getBaseApiUrl(); var dataManager = spread.dataManager(); var productTable = dataManager.addTable("productTable", { remote: { read: { url: baseApiUrl + "/Product" } } }); productTable.primaryKey("id"); var supplierTable = dataManager.addTable("supplierTable", { remote: { read: { url: baseApiUrl + "/Supplier" } } }); dataManager.addRelationship(productTable, "SupplierId", "supplier", supplierTable, "Id", "products"); Promise.all([productTable.fetch(), supplierTable.fetch()]).then(function () { spread.suspendPaint(); //set a DataObject celltype which use QUERY function to provide data sheet.setFormula(2, 1, '=QUERY("productTable?Id=1",,true)'); var cellType2 = new GC.Spread.Sheets.CellTypes.DataObject('=IFERROR(@.ProductName & " " & @.UnitPrice, "")'); sheet.setCellType(2, 1, cellType2); spread.resumePaint(); }); spread.resumePaint(); } function getBaseApiUrl() { return window.location.href.match(/http.+spreadjs\/demos\//)[0] + 'server/api'; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="ja-jp" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Promise Polyfill for IE, https://www.npmjs.com/package/promise-polyfill --> <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets-resources-ja/dist/gc.spread.sheets.resources.ja.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="ss" class="sample-spreadsheets"></div> <div id="optionContainer" class="optionContainer"> </div> </div> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; }