You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Sushama <su...@rave-tech.com> on 2005/08/04 16:46:57 UTC

Setting String value in cell

Hi,
I am trying to set "$CHEMSCAPE 1.0.0 0 2" value in the second cell of first row.
I have written following code which creats the excel file.But when I open the 
file the excel crashes.Can anyone explain me the same?
I have tried to set this value as a String explicitly but even that dosent work.
I want to set this string to get ISIS support for interpretation of data in 
excel file.
I have MDL ISIS installed on my machine.


public class TestISIS 
{
	public static void main(String[] args) 
	{
		try
		{
		
		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet1 = wb.createSheet("sheet");
	    	
		HSSFRow row0 = sheet1.createRow((short)0);
				
		row0.createCell((short)1).setCellValue("$CHEMSCAPE 1.0.0 0 2");
   
   /* HSSFCell cell = row0.createCell((short)1);
    cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    cell.setCellValue("$CHEMSCAPE");*/
  
		row1.createCell((short)1).setCellValue("abc");


		// Write the output to a file
		FileOutputStream fileOut = new FileOutputStream
("C:\\TestISIS.xls");
		wb.write(fileOut); 
		fileOut.close(); // if not closed then file is not created
		}catch(Exception e)
		{
			System.out.println("Exception "+e);
		}
	}
}



---------------------------------------------------------------------
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/


Re: Setting String value in cell

Posted by an...@superlinksoftware.com.
This code should not compile.  There is no "row1".  Most likely you're 
creating a row with no cells which is not legal IIRC.  We should detect 
that and auto-remove it when it is done.

-Andy

Sushama wrote:
> Hi,
> I am trying to set "$CHEMSCAPE 1.0.0 0 2" value in the second cell of first row.
> I have written following code which creats the excel file.But when I open the 
> file the excel crashes.Can anyone explain me the same?
> I have tried to set this value as a String explicitly but even that dosent work.
> I want to set this string to get ISIS support for interpretation of data in 
> excel file.
> I have MDL ISIS installed on my machine.
> 
> 
> public class TestISIS 
> {
> 	public static void main(String[] args) 
> 	{
> 		try
> 		{
> 		
> 		HSSFWorkbook wb = new HSSFWorkbook();
> 		HSSFSheet sheet1 = wb.createSheet("sheet");
> 	    	
> 		HSSFRow row0 = sheet1.createRow((short)0);
> 				
> 		row0.createCell((short)1).setCellValue("$CHEMSCAPE 1.0.0 0 2");
>    
>    /* HSSFCell cell = row0.createCell((short)1);
>     cell.setCellType(HSSFCell.CELL_TYPE_STRING);
>     cell.setCellValue("$CHEMSCAPE");*/
>   
> 		row1.createCell((short)1).setCellValue("abc");
> 
> 
> 		// Write the output to a file
> 		FileOutputStream fileOut = new FileOutputStream
> ("C:\\TestISIS.xls");
> 		wb.write(fileOut); 
> 		fileOut.close(); // if not closed then file is not created
> 		}catch(Exception e)
> 		{
> 			System.out.println("Exception "+e);
> 		}
> 	}
> }
> 
> 
> 
> ---------------------------------------------------------------------
> 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/
> .
> 


---------------------------------------------------------------------
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/