Table sum is not correct

attached is source and result.
the next to last table in the result doc (labeled cost advanced) the sum of the columns is showing as 4034.32, while the actual sum of the column is 1008.
Aspose.zip (15.7 KB)

using aspose 17.7

@conniem,

Thanks for your inquiry. Please try latest version of Aspose.Words for .NET 18.3. If you still face problem, please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

Thanks for your cooperation.

I think it’s something weird on the template, but I don’ t know what. I’m getting the same incorrect results when I generate it using word methods as well.
I’ve also tried recreating the table.

updated zip file to include the field list and the data used to fill it.
I will work on recreating a test app

Aspose.zip (16.3 KB)

AsposeTest.zip (36.0 KB)
This project includes semi working source code and the input files.
however, the source code has developed an issue, in that it will only clone 2 rows properly. after the 2nd row, it seems to not be able to find the merge fields in the newly cloned row(?).

I seem to be stuck on that issue. Please help with that.

@conniem,

Thanks for sharing the detail. We are investigating this issue and will get back to you soon.

@conniem,

Please note that Aspose.Words mimics the behavior of MS Word. If you update the field using MS Word, you will get the incorrect results also. In your case, we suggest you please use SUM(ABOVE) field to get the sum of amount.

Regarding your query about clone row issue, please use the following modified method. Hope this helps you.

static void fillFTable(Document AsposeDocument)
{
    // Clone template row.
    string s = Directory.GetCurrentDirectory();
    string dataList = File.ReadAllText(s + "\\values.txt");
    string fieldList = File.ReadAllText(s + "\\fields.txt");
    string[] rowData = dataList.Split('|');
    string[] fList = fieldList.Split((char)24);
    Aspose.Words.Tables.Table tbl = AsposeDocument.FirstSection.Body.Tables[0];
    Aspose.Words.Tables.Row cloneRow = tbl.Rows[2];
    Aspose.Words.Tables.Row newRow;
    newRow = (Aspose.Words.Tables.Row)cloneRow.Clone(true);
    for (int y = 0; y < rowData.Length; y++)
    {
        string[] colData = rowData[y].Split((char)24);

        AsposeDocument.MailMerge.Execute(fList, colData);

        tbl = AsposeDocument.FirstSection.Body.Tables[0];
        tbl.InsertBefore(newRow, tbl.LastRow);
    }
}

I made the changes to the code.
I made the changes to the template (replaced sub column with sum(above))
the total is still incorrect.
shows as 242.50 vs 1008.58

@conniem,

Thanks for your inquiry. Please ZIP and attach your modified input Word document here for testing. We will investigate the issue on our side and provide you more information.

Debug.zip (14.9 KB)
attached

@conniem,

Thanks for sharing the document. Please note that Aspose.Words mimics the behavior of MS Word. If you update the field using MS Word, you will get the same output.

In your case, we suggest you please remove the parentheses from the numeric values e.g. replace (187.00) with 187.00 to get the correct output. Hope this helps you.

well, here’s the problem… I can’t.
unless we require all of our users to remove all of the formatting of all the fields, that isn’t acceptable to us.
I understand the word is ‘broken’ in these cases, but I would expect that since I’m not using word, I would not run into word’s ‘bugs’.
Is there another solution?

here are other things that work in aspose, but not in word:
display format of $-(some number) - word excludes from the sum, aspose does not.
certain malformed ‘if’ statements:
IF «D.is_cash» = “N” “«D.qty» @ «D.rate»” “”

though this:
IF ^ “«D.is_cash»” ^ “=” ^ “N” ^ “«D.qty» @ «D.rate»” ^ “”
works in word, but does not in Aspose.

can you include the parenthesized negatives in the list?

@conniem,

Thanks for your inquiry. We are working over your query and will get back to you soon.

@conniem,

In this case, we suggest you following solution.

  1. Please iterate over the cells of last column and sum the numeric values.
  2. Insert the sum value in the desired cell of table using DocumentBuilder.Write method.

Please share your input, output, and expected output document along with code example to reproduce this issue. We will investigate the issue on our side and provide you more information.

for the if statement, see previous question under my name:
How to get an ‘IF’ statement to work?
I was told then, as I am now, to fix it myself.

again, I have 50+ user sites. each of these sites have hundreds of word templates that I am trying to convert to use aspose vs word to generate the output.
I can’t ‘willy nilly’ scan through a table and manually total up the sum, because the end users design their own templates, so the table may or may not have a sum on a column, and there is no way to tell if it’s there, or which column is being summed.

as for the $- working in aspose, and the malformed if statement working in aspose - DON’T TOUCH IT. I want it to work right…

@conniem,

Thanks for your inquiry. As per our understanding, the IF field in your template works using Aspose.Words. The only issue you are facing is the sum values of table’s cell. In your case, MS Word’s field SUM(ABOVE) also does not sum the values correctly.

Could you please elaborate the format of numeric values in your cases? We will then log a feature request to sum the column’s values in our issue tracking system.

the numeric format:
=SUM(above) # “$#,##0.00;($#,##0.00)”

the columns have the same numeric format

the ‘if’ statement that does NOT work in aspose - but does in word:
ex1 - IF ^ “«D.is_cash»” ^ “=” ^ “N” ^ “«D.qty» @ «D.rate»” ^ “” (the formula is displayed in the result)
ex2 - IF “«D.is_cash»” “=” “N” “«D.qty» @ «D.rate»” “” (returns ‘=’)

@conniem,

We have logged a feature request as WORDSNET-16581 in our issue tracking system to sum the values of table’s column. We will look into the possibility of implementation of this feature. Once the analysis of this feature is completed, we will then update you via this thread about it.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

for the sum issue, thank you for looking into it.
for the ‘if’ statement, research :

https://forum.aspose.com/t/in-response-to-www-aspose-com-community-forums-thread-847526-aspx/227

where I initially reported the issue. it contains a template, some input, and the methods I am required to use in order to make my templates work

Actually, ignore that last - the one with the malformed if statement.
I recalled why it works - its the delphi application that is generating the data in the word version of my application (old stuff), vs the new one which is using aspose and merge fields.
I apologize.