poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Lee <ag...@earthlink.net>
Subject Re: How to get "12345" to be a real string?
Date Tue, 04 Feb 2003 17:28:49 GMT
At 9:59 PM -0500 2/3/03, Andrew C. Oliver wrote:
>can you attach to a bug (see the get involved page):
>  1. The most simple code which replicates the issue.(executable)
>  2. The output from that, attached.
>  3. A hand-produced sheet which is the output you expect

Done (#16767).  Below is a copy of what I submitted (sans file 
attachments), in case anyone spots an obvious error in what I was 


The code below generates a 1-cell spreadsheet.  When I open it, the 
"12345" is left-justified, like I would expect a string value to be. 
But if I double-click the cell and then click out of it without 
making any changes, it becomes the integer 12345.

If I were creating the spreadsheet by hand I would have entered 
'12345 to force the value to be a string, and the apostrophe would be 
there when I double-click the cell.


import org.apache.poi.hssf.usermodel.*;
import java.io.*;

public class Test
     public static void main(String[] args)
         catch (Exception e)

     private static void doMain() throws Exception
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet = wb.createSheet("test");

         HSSFRow row = sheet.createRow((short)0);
         HSSFCell cell = row.createCell((short)0);


         FileOutputStream fos = new FileOutputStream("/tmp/test.xls");

View raw message