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

Free Support Forum - aspose.com

Sum Function in Excel

I am having a strange occurence from a spreadsheet that was built with aspose.
I have a column that has cells formatted as numbers. After opening spreadsheet I try to
sum the cells with no result. I type in exactly the same numbers that are in the cells produced by aspose and the sum function display the correct value.

Hi Bob,

That’s really a strange problem. Could you please send me your problem file?

How do I send you a file?

You can email it to me at excel@aspose.com.

Hi Bob,

I got your file and I found the data in all cells are strings.

If you want to put a numberic data to the result file, please don’t convert it to string.

For example,

double doubleValue = 12.34;

//Do not convert them to string
cell.PutValue(doubleValue.ToString()); //If you convert it to string, numeric functions in formula will not take effect


I thought that might be the case. My problem is that I am bringing in text print files.
It would be nice if we could switch a column to double, etc for an entire column. Your thoughts?



You can use Double.Parse(string) to convert your string to number. That’s easier and more controllable.

We would like to share that Aspose.Excel is discontinued now and an advanced version containing support for all the latest features in MS Excel is introduced named Aspose.Cells. This new product is much better in performance and provides rich features to support different requirements by wast range of developers. All the latest functions are supported and you can use sum function in this product using the following sample code:

// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();

// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];

// Adding a value to "A1" cell

// Adding a value to "A2" cell

// Adding a value to "A3" cell

// Adding a SUM formula to "A4" cell
worksheet.Cells["A4"].Formula = "=SUM(A1:A3)";

// Calculating the results of formulas

// Get the calculated value of the cell
string value = worksheet.Cells["A4"].Value.ToString();

// Saving the Excel file
workbook.Save(dataDir + "output.xls");

For more information on this topic, visit the following link:
Ways to calculate formulas

The latest version of the product is available here:
Aspose.Cells for .NET (Latest Version)

Variety of examples are available in a ready to run solution here.