Free Support Forum - aspose.com

GridCell and Style problem when using SetCellValue

When trying the code below, my desired output is "8,000 dollars" but it shows up as "8000 dollars" without the comma. If I comment out the SetCellValue line, I do get "8,000". Am I doing this incorrectly? I want to maintain the numberformat and append text at the end.

Aspose.Grid.Desktop.GridCell cell = mainWorkSheet.Cells[row, column];

Style formulaStyle = cell.GetStyle();
formulaStyle.NumberFormat = 3;
formulaStyle.CellLocked = cellLocked;
cell.SetStyle(formulaStyle);

cell.Value = "=(8*1000)";
cell.SetCellValue(cell.Value + " dollars");

Hi,

Thanks for considering Aspose.

I think you may try:

Aspose.Grid.Desktop.GridCell cell = mainWorkSheet.Cells[row, column];

Style formulaStyle = cell.GetStyle();
formulaStyle.NumberFormat = 5;
formulaStyle.CellLocked = cellLocked;
cell.SetStyle(formulaStyle);

cell.Value = "=(8*1000)";

Thank you.

Still not working...still shows up as "8000 dollars".

It works if I just have cell.value = "=(8*1000)"

result being "8,000"

but after that, I have the line

cell.SetCellValue(cell.Value + " dollars");

and that's when it shows up as "8000 dollars" versus "8,000 dollars".

Hi,

I think there is not any way that you will get a format like 8,000 dollars, you may check it in MS Excel. I think you can use like $ 8,000 instead. Please refer to my previous code snippet.

Thank you.

Using " dollars" might have been a bad example.

What if I wanted it to show up as "8,000 widgets" where the 8,000 is coming from a formula?

Hi,

Well 8,000 is just the format not the original number, the original value is 8000, so when you concatenate it with widgets it will become 8000 widgets. And I think this is same in MS Excel. Any how we will further look into it if we can make it and get back to you soon.

Thank you.