Cells を Microsoft に追加 Excel 数式ウォッチ ウィンドウ
Contents
[
Hide
]
考えられる使用シナリオ
Microsoft Excel ウォッチ ウィンドウは、セルの値とその数式をウィンドウで簡単に監視できる便利なツールです。開くことができますウォッチウィンドウMicrosoft Excel を使用して数式 > ウォッチ 窓.それはウォッチを追加検査用のセルを追加するために使用できるボタン。同様に、使用できますWorksheet.getCellWatches().add() セルを追加するメソッドウォッチウィンドウAspose.Cells API を使用します。
Cells を Microsoft に追加 Excel 数式ウォッチ ウィンドウ
次のサンプル コードは、セル C1 と E1 の数式を設定し、両方を追加します。ウォッチウィンドウ.次に、ワークブックを次のように保存します出力エクセルファイル.出力された Excel ファイルを開いて表示すると、ウォッチウィンドウ、このスクリーンショットに示すように、両方のセルが表示されます。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Put some integer values in cell A1 and A2. | |
ws.getCells().get("A1").putValue(10); | |
ws.getCells().get("A2").putValue(30); | |
// Access cell C1 and set its formula. | |
Cell c1 = ws.getCells().get("C1"); | |
c1.setFormula("=Sum(A1,A2)"); | |
// Add cell C1 into cell watches by name. | |
ws.getCellWatches().add(c1.getName()); | |
// Access cell E1 and set its formula. | |
Cell e1 = ws.getCells().get("E1"); | |
e1.setFormula("=A2*A1"); | |
// Add cell E1 into cell watches by its row and column indices. | |
ws.getCellWatches().add(e1.getRow(), e1.getColumn()); | |
// Save workbook to output XLSX format. | |
wb.save(outDir + "outputAddCellsToMicrosoftExcelFormulaWatchWindow.xlsx", SaveFormat.XLSX); |