We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.cells - macro alternative

I have an Excel xlsm file which obviously contains macros. What is the alternative to using macros using aspose.cells? Could I re-write the macro using your API?

@simple2code,
See the document with example code for your reference and let us know your feedback.
https://docs.aspose.com/display/cellsnet/Modifying+VBA+or+Macro+Code+using+Aspose.Cells

Hope, this helps a bit.

so I cannot run functions or sub at all? Does it mean I have to convert all code in the modules into some sort of automation code? Will the excel file still calculate and do chart re-draws while I update the Excel data via aspose?

@simple2code,

Yes, Aspose.Cells does not support to execuate or run macros/vba codes, so you have to convert all code using Aspose.Cells APIs accordingly. Aspose.Cells has its own formula calculation engine, you may even customize your re-calculations. Similarly, Aspose.Cells does draw charts or calculate its objects so you can directly take the image or render PDF for the chart present /drawn in the workbook without opening the output Excel file into MS Excel manually.

Thanks you for the response and I appreciate it a lot.
So if I use the Aspose.Cells API to convert the current code, I will be able to execute the same logic and update the cell data. Will I be able to call any Excel method like calculate to refresh the charts/graphs or is that even possible?

@simple2code,

Yes, using Aspose.Cells, you can calculate formulas dynamically in the spreadsheet and get the calculated results against those formulas at runtime. Similarly, you may refresh/calculate pivot tables and charts dynamically in code. See some documents with examples for your reference:

[Formulas Calculations]
https://docs.aspose.com/display/cellsnet/Using+Formulas+or+Functions+to+Process+Data
https://docs.aspose.com/display/cellsnet/Using+ICustomFunction+Feature
https://docs.aspose.com/display/cellsnet/Implement+Custom+Calculation+Engine+to+extend+the+Default+Calculation+Engine+of+Aspose.Cells

[Pivottable]
https://docs.aspose.com/display/cellsnet/Refresh+and+Calculate+Pivot+Table+having+Calculated+Items

[Charts]
https://docs.aspose.com/display/cellsnet/Chart+Rendering

Thanks again, above really helps. I will need to do some testing and see what happens–

@simple2code,

Sure, take your time to evaluate the samples and in the event of further queries or issue, feel free write us back, we will be happy to assist you soon.