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

Free Support Forum - aspose.com

An extra-space in the StringValue for the cells with different format

Hi Aspose team,

Let’s have the attached excel file with 2 cells with the same value = 1, but with different format:
1st with green has default (general) format
2nd with red has a custom format, indicated in the picture attached: CustomFormat.PNG

After reading with Aspose.Cells these 2 cells, we’ll notice that, even if their values are the same, their StringValue are different (the second cell has an extra-space in the end).

Sample C# code:

var excelDoc = new Workbook(“TestFiles\input.xls”);

foreach (Cell cell in excelDoc.Worksheets[0].Cells)
if (cell.Value != null)
Console.WriteLine(“Cell[{0},{1}] has Value={2}, StringValue={3}, and DisplayStrinValue={4}”, cell.Row, cell.Column, cell.Value.ToString().Replace(" “, “"), cell.StringValue.Replace(" ", "”), cell.DisplayStringValue.Replace(” ", “"));

After running the code above, we’ll notice that, even if the values are the same (=1), the StringValue and DisplayStringValue for the second cell have an extra-space in the end (in code I replaced the spaces with "” to highlight the spaces on the screen).

The expected StringValue for the second cell should be the same as for the first-one (independent of their format), without extra-spaces in the end.

Thank You in advance,

Vitalie Semenciuc
Senior Software Developer
IBM Romania

Hi Vitalie,

Thank you for contacting Aspose support.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for .NET, and we are able to replicate the said problem on our side. It seems that the API is adding an extra space for the cells values (read with StringValue & DisplayStringValue) formatted with custom pattern. We have logged this incident in our bug tracking system under the ticket CELLSNET-43800 for further investigation. Please allow us some time to properly look into the matter, and get back to you with updates in this regard.


Thanks for using Aspose.Cells.

We have looked into this issue further and found that it is not a bug but expected behavior of Aspose.Cells APIs.

Please note the api reference:

“The formatted cell value is same with what you can get from excel when
copying a cell as text(such as copying cell to text editor or exporting
to csv)”

Please see the value displayed in ms excel, the difference of the two
cells is obvious. If you copy B5 to any text editor, you will got "1 "
instead of “1”.