Bug 10778 - [PATCH]HOW-TO Example
Summary: [PATCH]HOW-TO Example
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-13 20:01 UTC by Sergei Kozello
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Kozello 2002-07-13 20:01:49 UTC
From the HO-TO example it is not clear how to set Unicode cell values and 
Unicode sheet names.
Comment 1 Sergei Kozello 2002-07-13 20:06:44 UTC
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,&quot;SheetName&quot;).</p>
---
>                     HSSFWorkbook.setSheetName
(sheetindex,&quot;SheetName&quot;,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>

Comment 2 Andy Oliver 2002-07-15 02:20:48 UTC
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.  
Comment 3 Andy Oliver 2002-07-21 03:24:54 UTC
Hi Sergi, was this not included in the last patch?  Can I close this?
Comment 4 Sergei Kozello 2002-07-21 10:09:53 UTC
The needed functionality was made in the patch for the Bug 10548, so this bug 
is closed.