Csv output difference between .net core and .net framework

CSV output adds a negative sign in core 3.1 version as below. This can be recreated with any version of Aspose >= 18.10

Note: Template has the cell style set to “Number” (0.00). template attached

Expected behavior is for csv to be produced with “0.00”. Is there a work around/fix to suppress the “-ive” sign in .net core version?

==================================

.net framework version output: (works as expected)

TAG_STRING,TAG_DECIMAL1,TAG_DECIMAL2,Aspose Version,.NET Version

Row1,1.23,0.00,Aspose Ver: 22.4.0,".NETFramework,Version=v4.8"

.net core 3.1 version output: (incorrect -0.00 output)

TAG_STRING,TAG_DECIMAL1,TAG_DECIMAL2,Aspose Version,.NET Version

Row1,1.23,-0.00,Aspose Ver: 22.4.0,".NETCoreApp,Version=v3.1"

Sample code to recreate:

using Aspose.Cells;
using System;
using System.Data;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;

namespace AsposeTester
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Starting...");

                var wkbkFilePath = @"c:\temp\template.xlsx";
                var outputPath = @"c:\temp\output.csv";

                var ds = CreateData();

                var ms = new MemoryStream(File.ReadAllBytes(wkbkFilePath));
                var populatedStream = new MemoryStream();
                var designer = new WorkbookDesigner();
                designer.Workbook = new Workbook(ms);
                ms.Position = 0;
                designer.SetDataSource(ds);
                designer.Process();
                designer.Workbook.CalculateFormula();

                designer.Workbook.Save(populatedStream, SaveFormat.Csv);
                populatedStream.Position = 0;
                File.WriteAllBytes(outputPath, populatedStream.ToArray());

                Console.WriteLine("Completed successfully...");

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        public static DataSet CreateData()
        {
            var dt = new DataTable("DATA");
            dt.Columns.Add(new DataColumn("TAG_STRING", typeof(System.String)));
            dt.Columns.Add(new DataColumn("TAG_DECIMAL1", typeof(System.Decimal)));
            dt.Columns.Add(new DataColumn("TAG_DECIMAL2", typeof(System.Decimal)));
            dt.Columns.Add(new DataColumn("TAG_ASPOSE_VERSION", typeof(System.String)));
            dt.Columns.Add(new DataColumn("TAG_NET_VERSION", typeof(System.String)));

            var row = dt.NewRow();
            row[0] = "Row1";
            row[1] = 1.2345;
            row[2] = -0.0008;
            row[3] = $"Aspose Ver: {Aspose.Cells.CellsHelper.GetVersion()}";
            row[4] = $"{Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName}";
            dt.Rows.Add(row);

            var ds = new DataSet();
            ds.Tables.Add(dt);
            return ds;
        }
    }

}

template.zip (7.6 KB)

@mkAspose,

Thanks for the template file.

I tested your scenario/case using a new .NET Core 3.1 project with latest version of Aspose.Cells on Windows 10, it works fine and as expected using your exact code. Here is my output content of the CSV file:
Row1, 1.23, 0, Aspose Ver: 22.4.0, .NETCoreApp,Version=v3.1

Also, find attached the output CSV file for your reference.
output.zip (281 Bytes)

Thanks for reviewing this.
If you open your output.csv in notepad (no excel) you will see “-0.00”

@mkAspose,

Thanks for the additional details.

I am able to reproduce the issue as you mentioned by using your sample and template file. I found CSV output adds a negative sign in .NET Core 3.1 version when viewing into notepad. The output looks ok though when viewing the output CSV into MS Excel manually. I have logged a ticket with an id “CELLSNETCORE-381” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@mkAspose,

This is to notify you that your issue has been resolved. This fix will be included in the next release (Aspose.Cells for .NET v22.5) scheduled for the second week of May 2022. You will also be notified when the next version is released.