Issue with total using Matrix


I am using Designer of FastReport.Net and as source I use an xsd where the columns that I added to the matrix are defined as decimal type just like this:

<xs:element name="Importo_x0020_capitale_x0020_2" type="xs:decimal" id="T8-14" nillable="true"/>

and yet the total by column is just a concatenation between 2 string as you can see in the pic attached here.

(200 + 300 = 200300 and not 500)

I had the same issue with total by row but here I solved doing a convert to Int32 as Anatoly suggested but here I do not know how to solve this.


Thanks in advance.

Comments

  • Can you send your data? I will check it and try to solve your problem.

  • Hi Anatoly,

    In this xsd all field are typed, some as string and some as decimal.

    From this xsd I created an xml file with dummy values just to create the datasource XML database.

    In a console app in c#, I injected the data into the report in this way:


    // "Garanzia" "T8"

          var drGaranzia = ds.Tables[8].NewRow();

          drGaranzia[4] = "MORTE";

          // "Importo capitale 1" type="xs:decimal" "T8-13"

          drGaranzia[13] = 150000D;

          // "Importo capitale 2" type="xs:decimal" "T8-14"

          drGaranzia[14] = 20000D;

          // "Importo tasse annuo" type="xs:decimal" "T8-11"

          drGaranzia[11] = 400D;

          ds.Tables[8].Rows.Add(drGaranzia);


          var drGaranzia2 = ds.Tables[8].NewRow();

          drGaranzia2[4] = "INVALIDITA' PERMAMENTE";

          // "Importo capitale 1" type="xs:decimal" "T8-13"

          drGaranzia2[13] = 350000D;

          // "Importo capitale 2" type="xs:decimal" "T8-14"

          drGaranzia2[14] = 40000D;

          // "Importo tasse annuo" type="xs:decimal" "T8-11"

          drGaranzia2[11] = 600D;

          ds.Tables[8].Rows.Add(drGaranzia2);

    rep.Load(@"C:\Prove su FastReport\ModuliContraentePolizza.frx");

          rep.RegisterData(ds);

          rep.Prepare();

          simpleExport.Export(rep, @"c:\Prove su FastReport\ModuliContraentePolizza.pdf");


    This works as you've seen in the previous email (attached pic where is showed the matrix with the values)

    As attachment you will find xsd and xml file.


    I thank you for your help.

  • Hi, Anatoly

    did you have had some chance to take a look at data I sent you, yet?


    Thanks.

  • Sorry, I can't deal with your problem.

  • ok, thanks Anatoly.

  • 안녕, 잘 했어 기사의 내용을 관리하는 방식과 웹 사이트의 모양과 느낌을 이해해야합니다. 당신은 정말로 위대한 일을하고 있습니다

    커네티컷 이민 변호사

  • Hello!

    When the column total in Matrix concatenates the values into a string (200300) instead of summing them (500), this means that the column in the report’s Dictionary has a System.String type (despite the xs:decimal in the XSD; either an old/manual import or a DataTable passed a string type, or the Matrix is concatenating the strings) .

    How to fix it:

    Open the Data -> Dictionary window, select the column within the TableDataSource, and make sure its DataType is set to System.Decimal (not System.String).

    Alternatively, explicitly convert the value to a number in the Matrix data cell expression:

    [ToDecimal([Table.Importo])]

    After that, the Matrix’s total cells will be added arithmetically.

    when preparing the report.

This discussion has been closed.