Verwendung der FormulaText Funktion in Aspose.Cells
Contents
[
Hide
]
FormulaText ist eine Funktion von Excel 2013 und späteren Versionen. Sie wird nicht von früheren Versionen wie Excel 2010 oder 2007 usw. unterstützt. Wie der Name schon sagt, druckt sie den Text der Formel, der in einer bestimmten Zelle vorhanden ist. Dieser Artikel zeigt Ihnen, wie Sie diese Funktion mit Aspose.Cells verwenden können.
Der folgende Beispielcode zeigt die Verwendung von FormulaText mit Aspose.Cells. Der Code schreibt zuerst eine Formel in Zelle A1 und druckt dann den Text der Formel mit FormulaText in Zelle A2.
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-.NET | |
// Create a workbook object | |
Workbook workbook = new Workbook(); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Put some formula in cell A1 | |
Cell cellA1 = worksheet.Cells["A1"]; | |
cellA1.Formula = "=Sum(B1:B10)"; | |
// Get the text of the formula in cell A2 using FORMULATEXT function | |
Cell cellA2 = worksheet.Cells["A2"]; | |
cellA2.Formula = "=FormulaText(A1)"; | |
// Calculate the workbook | |
workbook.CalculateFormula(); | |
// Print the results of A2, It will now print the text of the formula inside cell A1 | |
Console.WriteLine(cellA2.StringValue); |
Konsolenausgabe
Hier ist die Konsolenausgabe des obigen Beispielcodes.
=SUM(B1:B10)