Free Support Forum - aspose.com

Not able to get the sum of columns

Hi,

We are using Aspose Excel to generate reports. The format of the same is attached along.

We are quite satisfied with the results, however when we try to generate the sum of any of the columns of the generated report, we are unable to do so. For example, in the attached sheet, if we are trying to sum the values of J:5 to J:10, we are getting “0”(Zero) as the value. We even tried changing the format of the column to numeric but could not succeed in getting the desired result.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We also have a second issue.

We want to show the negative values in brackets (). Is there any facility to do so?

Kindly help us in this regard.

Warm Regards,
Ramesh J

Hi Ramesh,

How do you set value for column J? If you use the following code:

cell.PutValue(“100”);

The cell value will be a string, not a number. So the sum amount will be 0.

Please change your code to:
cell.PutValue(100);

To show negative values in brackets, you can use cell.Style.Number or cell.Style.Custom to set a desired number format. Or you can directly set the number format in your designer template file.