You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/02/04 18:26:46 UTC
DO NOT REPLY [Bug 16767] New: -
string "12345" becomes the number 12345
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16767>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16767
string "12345" becomes the number 12345
Summary: string "12345" becomes the number 12345
Product: POI
Version: 1.5.1
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: Normal
Priority: Other
Component: HSSF
AssignedTo: poi-dev@jakarta.apache.org
ReportedBy: aglee@earthlink.net
CC: aglee@earthlink.net
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.
--Andy
==========
import org.apache.poi.hssf.usermodel.*;
import java.io.*;
public class Test
{
public static void main(String[] args)
{
try
{
doMain();
}
catch (Exception e)
{
e.printStackTrace();
}
}
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);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("12345");
FileOutputStream fos = new FileOutputStream("/tmp/test.xls");
wb.write(fos);
fos.flush();
fos.close();
}
}