You can use the formula text box as a control on the page.
You can type or view the formula in the formula text box control as illustrated in the following image.
You can also select ranges of cells to add to the formula text box control. Select the formula range icon in the text box and then select multiple ranges by pressing the Ctrl key or by adding a comma (,) to the text box.
Using Code
This example adds a formula text box control to the page.你可以将公式输入框作为控件使用。
你可以在公式输入框中输入或查看公式。
你也可以通过选择单元格区域来在在公式输入框中输入一个单元格区域。
点击右侧的“选择区域” 按钮,你可以在工作表中选择一个区域并输入到公式输入框中。
按下 Ctrl 键来在公式输入框中输入逗号 “,”。
示例代码
以下代码在页面上创建了一个公式输入框。
JavaScript | Copy Code | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a2f5e133-18e2-4ca8-b4ee-096b6ef62593"><ac:plain-text-body><![CDATA[ | window.onload = function(){ var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3}); var activeSheet = spread.getActiveSheet();activeSheet.setArray(0, 0, [1, 2, 3, 4, 5]);var fbx = new GC.Spread.Sheets.FormulaTextBox.FormulaTextBox(document.getElementById("formulaTextBox"));fbx.workbook(spread); }...<input type="text" id="formulaTextBox" /> |
| ]]></ac:plain-text-body></ac:structured-macro> |
This example allows you to add selected ranges to the formula text box.以下代码允许你在公式输入框中选择单元格区域。
JavaScript | Copy Code |
<script type="text/javascript"> window.onload = function(){ var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 }); rangeSelector = new GC.Spread.Sheets.FormulaTextBox.FormulaTextBox(document.getElementById("ftb"), {rangeSelectMode: true}); rangeSelector.workbook(spread); } function buttonClick(){ alert(rangeSelector.text()); } </script>...<div id="ss" style="width:50%; height:400px; border:1px solid gray;"></div> <div id="ftb" style="width:50%;height:20px;border:1px solid gray"></div> <button onclick="buttonClick()">Get Range Text</button> |
|
See Also另见
FormulaTextBox class