You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Murali Krishna <mu...@yahoo.com> on 2005/10/19 03:34:10 UTC

green icon in the cell

Hi,
I am getting a small green icon in the cell when i insert a string which is numeric data in the excel cell. the exact message is "the number in this cell is formatted as text or preceded by an apostophe".
 
is there anyway I can get rid of that. Below is the sample code that I wrote.
 
Thanks,
Murali
 
 
public class IntFormatting {
 public static void main(String ar[]){
  
    HSSFWorkbook wb = new HSSFWorkbook();
     HSSFSheet sheet = wb.createSheet("format sheet");
     HSSFCellStyle style;
     HSSFDataFormat format = wb.createDataFormat();
     HSSFRow row;
     HSSFCell cell;
     short rowNum = 0;
     short colNum = 0;
     
     row = sheet.createRow(rowNum++);
     cell = row.createCell(colNum++);
     String s="1234343";
   
     cell.setCellValue(s);
     
     String file = "c:\\intformatting.xls";
     try{
      FileOutputStream fileOut = new FileOutputStream(file);
      wb.write(fileOut);
      fileOut.close();
     }
     catch(IOException ioe){
      ioe.printStackTrace();
     }
     System.out.println("output written to file : " + file);
 }
}


		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Re: green icon in the cell

Posted by Murali Krishna <mu...@yahoo.com>.
Hi Leen Toelen,
 
Thanks for the response. I have tried that before and after seeing your mail, with all the possible combinations of String, numeric, formula, error and blank. Still its not resolving my problem. Below is my code. please do let me know, whether i am making any mistake.
 
Thanks,
Murali
 
 
public class IntFormatting {
 public static void main(String ar[]){
  
    HSSFWorkbook wb = new HSSFWorkbook();
     HSSFSheet sheet = wb.createSheet("format sheet");
     HSSFCellStyle style;
     HSSFDataFormat format = wb.createDataFormat();
     HSSFRow row;
     HSSFCell cell;
     short rowNum = 0;
     short colNum = 0;
     row = sheet.createRow(rowNum++);
     cell = row.createCell(colNum++);
     String s="1234343";
     
     cell.setCellType(HSSFCell.CELL_TYPE_STRING);
     cell.setCellValue(s);
     
     String file = "c:\\intformatting.xls";
     try{
      FileOutputStream fileOut = new FileOutputStream(file);
      wb.write(fileOut);
      fileOut.close();
     }
     catch(IOException ioe){
      ioe.printStackTrace();
     }
     System.out.println("output written to file : " + file);
 }
}

Leen Toelen <to...@gmail.com> wrote:
Hi,

setCellType to the rescue:

void setCellType(int cellType)
set the cells type (numeric, formula or string)

Regards,
Leen Toelen

On 10/19/05, Murali Krishna wrote:
> Hi,
> I am getting a small green icon in the cell when i insert a string which is numeric data in the excel cell. the exact message is "the number in this cell is formatted as text or preceded by an apostophe".
>
> is there anyway I can get rid of that. Below is the sample code that I wrote.
>
> Thanks,
> Murali
>
>
> public class IntFormatting {
> public static void main(String ar[]){
>
> HSSFWorkbook wb = new HSSFWorkbook();
> HSSFSheet sheet = wb.createSheet("format sheet");
> HSSFCellStyle style;
> HSSFDataFormat format = wb.createDataFormat();
> HSSFRow row;
> HSSFCell cell;
> short rowNum = 0;
> short colNum = 0;
>
> row = sheet.createRow(rowNum++);
> cell = row.createCell(colNum++);
> String s="1234343";
>
> cell.setCellValue(s);
>
> String file = "c:\\intformatting.xls";
> try{
> FileOutputStream fileOut = new FileOutputStream(file);
> wb.write(fileOut);
> fileOut.close();
> }
> catch(IOException ioe){
> ioe.printStackTrace();
> }
> System.out.println("output written to file : " + file);
> }
> }
>
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/


		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Re: green icon in the cell

Posted by Leen Toelen <to...@gmail.com>.
Hi,

setCellType to the rescue:

void 	setCellType(int cellType)
          set the cells type (numeric, formula or string)

Regards,
Leen Toelen

On 10/19/05, Murali Krishna <mu...@yahoo.com> wrote:
> Hi,
> I am getting a small green icon in the cell when i insert a string which is numeric data in the excel cell. the exact message is "the number in this cell is formatted as text or preceded by an apostophe".
>
> is there anyway I can get rid of that. Below is the sample code that I wrote.
>
> Thanks,
> Murali
>
>
> public class IntFormatting {
>  public static void main(String ar[]){
>
>     HSSFWorkbook wb = new HSSFWorkbook();
>      HSSFSheet sheet = wb.createSheet("format sheet");
>      HSSFCellStyle style;
>      HSSFDataFormat format = wb.createDataFormat();
>      HSSFRow row;
>      HSSFCell cell;
>      short rowNum = 0;
>      short colNum = 0;
>
>      row = sheet.createRow(rowNum++);
>      cell = row.createCell(colNum++);
>      String s="1234343";
>
>      cell.setCellValue(s);
>
>      String file = "c:\\intformatting.xls";
>      try{
>       FileOutputStream fileOut = new FileOutputStream(file);
>       wb.write(fileOut);
>       fileOut.close();
>      }
>      catch(IOException ioe){
>       ioe.printStackTrace();
>      }
>      System.out.println("output written to file : " + file);
>  }
> }
>
>
>
> ---------------------------------
>  Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/