We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NumberFormat is not working properly

I tried to get a cell format by calling NumberFormat property, the cell has a custom format as below:
_(* 0.0%_);_(* -0.0%_);_(* "-"??_);_(@_)
but when I got the result of the property it has a "\" before "-" as shown below:
_(* 0.0%_);_(* \-0.0%_);_(* "-"??_);_(@_)
I attached the file, would you please help me in this issue, I believe the property should return the same cell format.aspose- cell format method issue.zip (12.1 KB)

@raha_Hosseini
It’s same as data in the file:

    	<numFmts count="1">
    		<numFmt numFmtId="164" formatCode="_(* 0.0%_);_(* \-0.0%_);_(* &quot;-&quot;??_);_(@_)"/>
    	</numFmts> 

“\” Indicates that the following character is constant.

1 Like

image.png (582.5 KB)

Thank you Simon for your response. But I’ve seen different cell format in the file, I’ve seen what is shown in the above picture, would you please elaborate how did you get the cell format? because what I found is a little different.
Thank you

@raha_Hosseini,
The format pattern string is got from the data saved in the template file. Ms excel may show the custom string differently from the actual data it holds in its data model for the style, such as according to different regional settings and environments. For our component, the data may come from existing template file, or be assigned by user’s code directly. We have to return the original data for user to manipulate this property directly.

1 Like

Thank you very much for the clarification, but I actually copy and paste the first one in the customs format, and when I save it and run the Aspose method it return the second one, actually this is my problem. as you said it should return the original data, but now it returns something else.
can I make myself understood?

@raha_Hosseini
We performed your steps in ms excel and found ms excel added ‘\’ into the pattern automatically, so there is extra ‘\’ in the xlsx file saved by ms excel. We are afraid for such situation we cannot help much because it is ms excel’s behavior.

1 Like

I see. Thank you for the clarification and your time.

@raha_Hosseini,

You are welcome.