From the HO-TO example it is not clear how to set Unicode cell values and Unicode sheet names.
The wanted functionality has been added to the example. Index: src/documentation/xdocs/hssf/how-to.xml =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/documentation/xdocs/hssf/how-to.xml,v retrieving revision 1.12 diff -r1.12 how-to.xml 45c45,48 < HSSFWorkbook.setSheetName (sheetindex,"SheetName").</p> --- > HSSFWorkbook.setSheetName (sheetindex,"SheetName",encoding). > The name may be in 8bit format (HSSFWorkbook.ENCODING_COMPRESSED_UNICODE) > or Unicode (HSSFWorkbook.ENCODING_UTF_16). Default encoding is 8bit per char. > </p> 101,102c104,105 < //make it red < f.setColor((short) HSSFColor.RED.index); --- > //make it blue > f.setColor( (short)0xc ); 105c108 < f.setBoldweight(f.BOLDWEIGHT_BOLD); --- > f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); 109,110c112,113 < //make it the color at palette index 0xf (white) < f2.setColor((short) HSSFColor.WHITE.index); --- > //make it red > f2.setColor( (short)HSSFFont.COLOR_RED ); 112c115,117 < f2.setBoldweight(f2.BOLDWEIGHT_BOLD); --- > f2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); > > f2.setStrikeout( true ); 123,124d127 < // set foreground fill to red < cs2.setFillForegroundColor((short) HSSFColor.RED.index); 130,132c133,136 < wb.setSheetName(0, "HSSF Test"); < // create a sheet with 300 rows (0-299) < for (rownum = (short) 0; rownum < 300; rownum++) --- > wb.setSheetName(0, "’¥á⮢ ï ‘âà ¨çª ", HSSFWorkbook.ENCODING_UTF_16 ); > // wb.setSheetName(0, "HSSF Test", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE ); > // create a sheet with 30 rows (0-29) > for (rownum = (short) 0; rownum < 30; rownum++) 144,145c148,149 < // create 50 cells (0-49) (the += 2 becomes apparent later < for (short cellnum = (short) 0; cellnum < 50; cellnum += 2) --- > // create 10 cells (0-9) (the += 2 becomes apparent later > for (short cellnum = (short) 0; cellnum < 10; cellnum += 2) 153a158,162 > String cellValue; > > // create a string cell (see why += 2 in the > c = r.createCell((short) (cellnum + 1)); > 158a168,170 > // set the cell's string value to "TEST" > c.setEncoding( HSSFCell.ENCODING_COMPRESSED_UNICODE ); > c.setCellValue( "Test" ); 160,170c172 < < // create a string cell (see why += 2 in the < c = r.createCell((short) (cellnum + 1)); < < // set the cell's string value to "TEST" < c.setCellValue("TEST"); < // make this column a bit wider < s.setColumnWidth((short) (cellnum + 1), (short) ((50 * 8) / ((double) 1 / 20))); < < // on every other row < if ((rownum % 2) == 0) --- > else 172,173d173 < // set this to the white on red cell style < // we defined above 174a175,177 > // set the cell's string value to "’¥á⨪" > c.setEncoding( HSSFCell.ENCODING_UTF_16 ); > c.setCellValue( "’¥á⨪" ); 176a180,182 > > // make this column a bit wider > s.setColumnWidth((short) (cellnum + 1), (short) ((50 * 8) / ((double) 1 / 20))); 386,390c392,396 < <li>download the poi-alpha build and untar it (tar xvzf < tarball.tar.gz) < </li> < <li>set up your classpath as follows: < <code>export HSSFDIR={wherever you put HSSF's jar files} --- > <li>download the poi-alpha build and untar it (tar xvzf > tarball.tar.gz) > </li> > <li>set up your classpath as follows: > <code>export HSSFDIR={wherever you put HSSF's jar files} 393,394c399,400 < </li><li>type: < <code>java org.apache.poi.hssf.dev.HSSF ~/myxls.xls write</code></li> --- > </li><li>type: > <code>java org.apache.poi.hssf.dev.HSSF ~/myxls.xls write</code></li> 399,400c405,406 < <li>Type: < <code>java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls</code> --- > <li>Type: > <code>java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls</code>
Thank you for this patch. please resubmit this as an attachment (cut and paste always garbles patches) and I'll apply it. Its best if you use cvs diff -u instead of the standard mode. Take a look at the bottom of http://jakarta.apache.org/poi/getinvolved/index.html if you don't know what I mean.
Hi Sergi, was this not included in the last patch? Can I close this?
The needed functionality was made in the patch for the Bug 10548, so this bug is closed.