开发者

how to set number format to cells using jexcel api

I am writing a excel sheet with various floating values . It is absolutely necessary that i do not lose any decimal point when doing this. I am using this code:

              number = new Number(1, rowno2,biashidden[i]);
              sheet.addCell(number);

When i do this, the default format is only up to 3 decimal places. I can see the values written correctly in the excel sheet, but when do System.out.println , i see only values upto 3 decimal places. I do not know upto how man开发者_如何学Cy places the values will be, it may be 1.0 or it may 1.0000045667 ( thus i cannot specify a maximum limit using Numberformat too). What should i do? Thanks in advance


This is the code for my problem .

        WritableCellFormat wcf1=new WritableCellFormat(new  jxl.write.NumberFormat("#.###############"));
         wcf1.setShrinkToFit(true);
        try
         {
                   for(int i=0;i<=numberOfNeurons[0];i++)
         {
                          for(int j=0;j<numberOfNeurons[1];j++)
            {
               number = new Number(0,rowno1,wtofnetwork[i][j],wcf1);

    sheet.addCell(number);
            rowno1++;

            }
             }

For some reason, we cannot specify the number of decimal places dynamically. so i gave enough decimal places so that no digit is lost. It is a crude way of doing it , but it achieves the purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜