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

Free Support Forum - aspose.com

GridWeb Cell Type

Hi,


I'm using the GridWeb control. How can I change the cell format type?


For example I type 6.0 and then click save it changes to 6


For my implementation it must stay unaltered?


Thanks in advance.

Hi,


Well, this is MS Excel’s behavior, so when a value has 0 in the first decimal place, it will omit it accordingly. I think for your needs, you have to specify the numbers formatting accordingly, you may add a few lines of code in the Page_Load event for your needs, see the sample code below:
e.g
Sample code:

WebWorksheet worksheet = GridWeb1.WebWorksheets[0];
WebCell cell = worksheet.Cells[“A1”];
Aspose.Cells.GridWeb.TableItemStyle style = new Aspose.Cells.GridWeb.TableItemStyle();
style.Custom = “0.0”;

Hope, this helps a bit.

Thank you.

Hi,

Thanks for the code snippet. Is there any way to apply this to a range of cells? i.e. all of column B

Thanks again.

Hi,


I think you may try to apply the style to a range of cells in the column, see the sample code below:
e.g
Sample code:

WebWorksheet worksheet = GridWeb1.WebWorksheets[0];
WebCell cell = worksheet.Cells[“A1”];
Aspose.Cells.GridWeb.TableItemStyle style = cell.GetStyle();
style.Custom = “0.0”;

worksheet.Cells.SetStyle(“B1:B100”, style);

Thank you.

Thanks again. Seeing some strange behaviour now. Is it expected that each time you click the save button on the control it adds more and more empty rows into the control?

Hi,


I tested your scenario/ case a bit. I could not spot the issue “each time you click the save button on the control it adds more and more empty rows into the control”. Could you provide us a sample project (runnable) with v8.0.0.2xxxx, we will check it soon.

Thank you.

Hi,

I got round that problem, but I have now noticed a new bug. If you change the format as per your suggestion the text is displayed correctly in gridweb, however that change is lost whenever you use the Export method to get the data into a data table?

Hi,


Could you create a simple project (runnable) with v8.0.0.2xxxx, zip it and post it here to reproduce the issue “If you change the format as per your suggestion the text is displayed correctly in gridweb, however that change is lost whenever you use the Export method to get the data into a data table” on our end, we will check it soon.

Thank you.