Custom negative number rendered incorrectly to PDF

Hi guys,
we face quite simple situation.

Attached XLSX when opened in EXCEL displays “Custom style” numbers correctly -> -429,17
Based on Region set. In my case (Czech (Czechia))
Latest Aspose.Cells renders such numbers like (i guess) US accounting style -> (429,17)

And it happens even if i explicitly set Region:

                var workbook = new Aspose.Cells.Workbook("C:\\temp\\minus.xlsx");
                workbook.Settings.Region = Aspose.Cells.CountryCode.Czech;
                var cell = workbook.Worksheets[0].Cells["A2"];
                var cellStyle = cell.GetStyle();
                workbook.Save("C:\\temp\\minus.pdf", Aspose.Cells.SaveFormat.Pdf);

Please, what could be wrong here?
Thanks and best regards!

minus.zip (34.2 KB)

@ondrej.hanak,

Thanks for the sample code, template file and details.

Please notice, I am able to observe the issue as you mentioned by using your sample code with your template file. The custom negative numbers are not rendered fine in the output PDF. I have logged a ticket with an id “CELLSNET-47545” for your issue. We will look into it soon.

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

1 Like

@ondrej.hanak,

Please try our latest version/fix: Aspose.Cells for .NET v20.8.1 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells20.8.1 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.8.1 For .Net4.0.Zip (5.4 MB)

Hi @Amjad_Sahi,
thanks for your update!

It works for Czech culture correctly now - perfect.
BUT it still doesn’t work for others, like Switzerland or Poland,…

I think it should work same like in Excel, correct?
What formatting you can see in Excel for given user culture, same format should contain produced PDF.

Please, could you check that?
Thank you and best regards!

@ondrej.hanak,

Did you try using the following lines to render in respective locales:
e.g

//To render in Switzerland region.
workbook.Settings.Region = Aspose.Cells.CountryCode.Switzerland;



//To render in Poland region.
workbook.Settings.Region = Aspose.Cells.CountryCode.Poland; 

Do you find any issue?

Hi @Amjad_Sahi,
yes i tried exactly these and result is incorrect, en-US format is used.

@ondrej.hanak,

Please create separate threads for each issue with details, sample code, template file(s) and screenshots. We will evaluate and may log appropriate tickets for the issue(s).

Man, are you serious?
It’s exactly the same thing just with different Aspose.Cells.CountryCode.
Did you try the same XLSX and code?
Just instead of

 workbook.Settings.Region = Aspose.Cells.CountryCode.Czech;

use

workbook.Settings.Region = Aspose.Cells.CountryCode.Switzerland;

Should i create 50 new threads for each wrong CountryCode?

@ondrej.hanak,

We cannot support all country codes or locales for rendering, we only support mostly used country codes. I asked you to create different threads as it will be easier for us to manage each issue/request precisely. Each support request for a specific locale demands to add certain modules (internally) for the task. Anyways, you may provide details on which other country codes you are interested, so we can evaluate each one and log appropriate tickets.

Hi @Amjad_Sahi,
Imagine you do NOT set any CountryCode like this:

            var workbook = new Aspose.Cells.Workbook("C:\\temp\\minus.xlsx");               
            workbook.Save("C:\\temp\\minus.pdf", Aspose.Cells.SaveFormat.Pdf);

It means basically:

            workbook.Settings.Region = Aspose.Cells.CountryCode.Default;

According to Aspose.Cells reference: WorkbookSettings.Region | Aspose.Cells for .NET API Reference

“…So, we use the regional settings of application’s environment for the workbook…”

BUT you don’t.
If my regional settings are German (Switzerland), US settings are used to render “negative numbers”.

There is not like list of cultures, which work and which not.
One would expect that all CountryCodes from this public enum:

public enum CountryCode
{
    Default = 0,
    USA = 1,
    Canada = 2,
    LatinAmeric = 3,
    Russia = 7,
    Egypt = 20,
    Greece = 30,
    Netherlands = 31,
    Belgium = 32,
    ....

would work.
BUT some of them work and some of them don’t.

It would be cool, if you could fix/test all these listed in this enum.
And update docu?

For the moment my interest is just in

  workbook.Settings.Region = Aspose.Cells.CountryCode.Switzerland;

Thank you and best regards!

@ondrej.hanak,

Please note, WorkbookSettings.Region attribute’s description applies when you are saving to MS Excel file formats. If you are rendering to PDF or image format, you need to specify the relevant region/locale/language settings in code before rendering to PDF/image format.

For your needs (to support Switzerland region/locale) when rendering to PDF, I have logged a separate ticket with an id “CELLSNET-47558” for your issue. We will look into it to fix it soon.

Hi @Amjad_Sahi,
thanks!

I think, you are not right.
There is no such precondition (to explicitly set Region in code) mentioned in Aspose docu: Pdf|Documentation

And all my tests show exactly the same.
It’s perfectly enough to set Region for runtime env in Windows for given user to get correct rendition.
For example if i set German (Germany):

image.jpg (145.8 KB)

And code looks like this:

        var workbook = new Aspose.Cells.Workbook("C:\\temp\\minus.xlsx");               
        workbook.Save("C:\\temp\\minus.pdf", Aspose.Cells.SaveFormat.Pdf);

Correct rendition is produced → German format for negative number “-429,17” is used.
If i set this:

image.jpg (144.2 KB)

US format for negative number “(429.17)” is used.

Best regards!

@ondrej.hanak,

Sorry for the confusion.

May be I misunderstood you. My point was if you need to render to PDF format in different region than the default one of your environment, you need to specify the region in code. For example, if we use us-english regional settings/locale in Windows, then if we need to render to PDF in German settings, we got to specify the region in code via Aspose.Cells. But, for a workbook without user’s specified region, such as loaded from XLSX file, or newly instantiated empty workbook, the region used for formatting will actually be the environment’s default region. So, in this case, yes, you are right.

Well, you know, there are so many combinations of languages and countries. And, for every combination, we need to test it in MS Excel with corresponding settings to get and verify the rules. But we cannot guarantee that our current formatting model will work for all regions.

Anyways, for your current requirements, we have enhanced our formatting model further to support more regions and we will give you a new fix for testing soon.

We are sorry for any inconvenience caused!

@ondrej.hanak,
Please try our latest version/fix: Aspose.Cells for .NET v20.8.2 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells20.8.2 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.8.2 For .Net4.0.Zip (5.4 MB)
Aspose.Cells20.8.2 For .NetStandard20.Zip (5.4 MB)

Hi @ahsaniqbalsidiqui,
looks okay now in Swiss env.

Thank you!

@ondrej.hanak,

Thanks for your feedback.

Good to know that your issue is sorted out now. In the event of further queries or issue, feel free to contact us any time, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-47545,CELLSNET-47558) have been fixed in Aspose.Cells for .NET v20.9. This message was posted using Bugs notification tool by Amjad_Sahi
You may also get the new version @ nuget repos. (NuGet Gallery | Aspose.Cells 20.9.0)