Load or Import CSV file with Formulas using C++
Contents
[
Hide
]
CSV files mostly contain textual data and do not typically include any formulas. However, there are cases when CSV files might contain formulas. Such CSV files should be loaded by setting the TxtLoadOptions.GetHasFormula() to true. Once this property is set to true, Aspose.Cells will not treat formulas as simple text. They will be treated as formulas, and the Aspose.Cells formula calculation engine will process them as usual.
The following code illustrates how you can load and import a CSV file with formulas. You can use any CSV file. For illustration purposes, we use the simple csv file which contains this data. As you see, it contains a formula.
300,500,=Sum(A1:B1)
The code first loads the CSV file, then imports it again at cell D4. Finally, it saves the workbook object in XLSX format. The output XLSX file looks like this. As you see, cell C3 and F4 contain formulas and their result is 800.
![]() |
---|