With previous Aspose.Cells dll version cell.StringValue = "$1,234.00"
but with current Aspose.Cells dll version cell.StringValue = "$1,234.00 " (space is preserved).
This happens when we have cell with value "$1,234.00 ".
Please let us know why this is happening?
Hi,
Well, surely when you have a cell with a value e.g "$1,234.00 " (a space at the end), Aspose.Cells would give you "$1,234.00 " as string value as space is itself a string character. I think you may try to trim your unwanted space by yourself if you want.
Thank you.
But with previous versions we did not need to trim the values.
With this change, we have to change where ever it is used, which will be very lengthy and tiring task for us.
So my question is all of sudden why it got changed in latest version of Aspose, Is it any specific reason that Aspose stop trimming the cell.StringValue extra spaces, can you please verify the behaviour on your end, wouldn't it be easy for user if Aspose trim out the end spaces ?
Hi,
I have tested your scenario/ case with a template file (attached). I have applied (numbers) custom formattings to two cells A1 and A2. On A1 cell, I applied “#,##0.00” where as I set "#,##0.00 " to A2 cell in MS Excel manually. Now I use Aspose.Cells to open the file and get its string value from the two cells. Well, I think it works fine, if you could see the string in MS Excel for A2 cell, it does have space char to the right end so does Aspose.Cells give the string, see the sample code with comments:
e.g
Sample code:
var book = new Workbook(“e:\test2\Bk_extraspace1.xlsx”);
//It does not have extra space i.e. “#,##0.00” format is set
Console.WriteLine(book.Worksheets[0].Cells[“A1”].StringValue);//prints “1,234.00” - OK
//It does have extra space i.e. "#,##0.00 " format is set
Console.WriteLine(book.Worksheets[0].Cells[“A2”].StringValue); //prints "1,234.00 " - OK
Thank you.
Hi,
We think it is the correct behavior and it might be a bug in the previous version. Could you give us details which version you are talking about, give us version number, we will check it further.
Thank you.
Hi,
We are currently using Aspose.Cells version 7.4.0.4.
Hi,
We have evaluated your issue further.
We are afraid we cannot recover or rollback to the older behavior. In fact the current value with extra spaces attached is also required by our other users and it is same with what you can get and expect from MS Excel manually. For the old behavior of Cell.StringValue, it was actually ambiguous for keeping/deleting spaces for cell’s formatted value. In newer versions, Cell.StringValue gives definite and valid results that is same with what you can get when copying the cell as text manually.
Thanks for your understanding!