Custom number format with negative number is not showing up in PDF on Linux container

Hi,

I have an excel template with a currency string format through Tostring(“C”). I am saving the file as pdf through stream by using aspose. Cell 22.2.0 I need to show the currancy numbers when they are negative in parentheses. That completely works in my local testing but in Linux container the style is removed. Could you please help me? Thanks

@Lauragoa,
Would you like to provide your sample file? Take a screenshot and highlight the error section. Thank you.

@Lauragoa,

We are not sure what’s the difference between the result of your local testing and the result of linux container. If you provide more details about the issue(such as the template files, different results of both environments, …), we can know it better and will try to figure it out soon.

By the way, now that the style can work for you in local testing, we think one possible reason for that different behavior may be environment settings such as the locale/region used by the application. So you may please try to set the same locale/region for the workbook( Region) for your program and test whether it can give same result for both environments.

Sure. This is the code :slight_smile:
var z =Convert.ToDecimal(-126.45).ToString(“C”, CultureInfo.CurrentCulture);
WorkbookDesigner wd = new WorkbookDesigner();
wd.Workbook = new Workbook(Path.Combine(“C:\Users\laura\”, “test.xlsx”));
Worksheet ws = wd.Workbook.Worksheets[0];
var FOFList = new List();
FOFList.Add( new FOFList() { Principal = z });
wd.SetDataSource(“FOFList”, FOFList);
wd.Workbook.CalculateFormula();
wd.Process(false);
PdfSaveOptions options = new PdfSaveOptions();
ws.PageSetup.PaperSize = PaperSizeType.Paper9x11;
ws.PageSetup.Orientation = PageOrientationType.Landscape;
wd.Workbook.Save(“mahsan.pdf”);
and I dont know how to attach the file here but I have created the excel file test.excel with general type column and put this in a header of the first column header Prinicpal and thevalue is '&=[FOFList].Principal. In debugging localy it is working but when I send it to the server it is showing negative and removes parenthesis.

@Lauragoa,

It looks like your local environment and server environment are different with different locale/regional settings. That’s why it works in your local environment but not on the server. What are the locale/regional settings of your local environment and server environment, give details? So, you should specify the same locale/regional settings of your local environment (where it works as expected) in code. As @johnson.shi recommended, you may add a line to use Workbook.Settings.Region attribute to set the region (of your local environment). Moreover, to share your Excel file, please zip it first prior attaching.

@Lauragoa,

And please confirm the variable “z” in your code contains the same string value in both environments. When you setting string value to a cell, commonly it will not be changed. So, if there is no special settings for your template file, the content output to the pdf should be just the value of “z”.

I added the settings.region=countrycode.USA and also as I said the value in my local debug and the server for this cell is the same. Something which I found out on our server we are saving the pdf to a memory stream and we are uploading the file through memory stream on s3. Something like this
Memorystream stream=new memorystream();
wd.workbook.save(stream,saveformat.pd);
Uploadwithstream(stream,bucket);

The same issue is persisting. When I debug locally it save the file on s3 with no issue with parenthesis but when I push the code to the server it’s showing the negative values like -$126.45 instead of ($126.45) and removes parenthesis and just showing the string format that I have in code. I even tried to use custom format through c# but still is not working. Please help. We have a time limitation.

@Lauragoa,

Please save the workbook as xlsx file instead of pdf in both environments and then provide us the generated xlsx files. We think there must be some differences that cause different pdf results and we should be able to figure the issue out according to them. And it will be better If you provide the template file together so we can run your code to test the issue at our end.

You may zip those files and then upload it here when you reply this topic. Thank you.