Exist Formula and Macros in worksheet?

Hello there,

I have to check if user have used formulas in a worksheet?? Is it possible???

And another question, I can check if macros exist in a workbook but can I check if aworksheet contains macros???


Thanks in advance

Hi,


Thank you for contacting Aspose support.

Regarding the first part of your inquiry, you can use the Find feature of Aspose.Cells APIs to check if a given worksheet has any formula in its cells. Please check the following piece of code and attached input spreadsheet for your reference.

C#

var book = new Workbook(dir + “book1.xls”);
var cells = book.Worksheets[0].Cells;
FindOptions opts = new FindOptions();
opts.LookInType = LookInType.OnlyFormulas;
opts.LookAtType = LookAtType.StartWith;
Cell cell = null;
do
{
cell = cells.Find(“=”, cell, opts);
if (cell != null)
{
Console.WriteLine(cell.Name);
}
} while (cell != null);


Regarding the detection of macros, you have to use the Workbook.HasMacro property to check if a spreadsheet has macros or not. Unfortunately, this feature is not available at worksheet level.