You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2016/06/02 15:06:29 UTC

svn commit: r1746586 - in /poi/site: publish/spreadsheet/quick-guide.html src/documentation/content/xdocs/spreadsheet/quick-guide.xml

Author: nick
Date: Thu Jun  2 15:06:29 2016
New Revision: 1746586

URL: http://svn.apache.org/viewvc?rev=1746586&view=rev
Log:
SS RichText info and code from examples

Modified:
    poi/site/publish/spreadsheet/quick-guide.html
    poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml

Modified: poi/site/publish/spreadsheet/quick-guide.html
URL: http://svn.apache.org/viewvc/poi/site/publish/spreadsheet/quick-guide.html?rev=1746586&r1=1746585&r2=1746586&view=diff
==============================================================================
--- poi/site/publish/spreadsheet/quick-guide.html (original)
+++ poi/site/publish/spreadsheet/quick-guide.html Thu Jun  2 15:06:29 2016
@@ -373,6 +373,10 @@ if (VERSION > 3) {
 <li>
 <a href="#PivotTable">Create a Pivot Table</a>
 </li>
+                    
+<li>
+<a href="#RichText">Cells with multiple styles</a>
+</li>
                 
 </ul>
             
@@ -1745,7 +1749,7 @@ Examples:
                 
                 
 <a name="Outlining"></a>
-                <a name="Outlining-N103E7"></a>
+                <a name="Outlining-N103EC"></a>
 <div class="h2">
 <h2>Outlining</h2>
 </div>
@@ -1792,7 +1796,7 @@ Examples:
         
         
 <a name="Images"></a>
-        <a name="Images-N10404"></a>
+        <a name="Images-N10409"></a>
 <div class="h3">
 <h3>Images</h3>
 </div>
@@ -3043,6 +3047,69 @@ the data to populate another drop down l
   pivotTable.addReportFilter(3);
         </pre>
       
+      
+<a name="RichText"></a>
+      <a name="Cells+with+multiple+styles+%28Rich+Text+Strings%29"></a>
+<div class="h3">
+<h3>Cells with multiple styles (Rich Text Strings)</h3>
+</div>
+        
+<p>
+         To apply a single set of text formatting (colour, style, font etc)
+         to a cell, you should create a 
+         <a href="/apidocs/org/apache/poi/ss/usermodel/CellStyle.html">CellStyle</a>
+         for the workbook, then apply to the cells.
+        </p>
+        
+<pre class="code">
+  // HSSF Example
+  HSSFCell hssfCell = row.createCell(idx);
+  //rich text consists of two runs
+  HSSFRichTextString richString = new HSSFRichTextString( "Hello, World!" );
+  richString.applyFont( 0, 6, font1 );
+  richString.applyFont( 6, 13, font2 );
+  hssfCell.setCellValue( richString );
+
+
+  // XSSF Example
+  XSSFCell cell = row.createCell(1);
+  XSSFRichTextString rt = new XSSFRichTextString("The quick brown fox");
+
+  XSSFFont font1 = wb.createFont();
+  font1.setBold(true);
+  font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
+  rt.applyFont(0, 10, font1);
+
+  XSSFFont font2 = wb.createFont();
+  font2.setItalic(true);
+  font2.setUnderline(XSSFFont.U_DOUBLE);
+  font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
+  rt.applyFont(10, 19, font2);
+
+  XSSFFont font3 = wb.createFont();
+  font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
+  rt.append(" Jumped over the lazy dog", font3);
+
+  cell.setCellValue(rt);
+        </pre>
+        
+<p>
+         To apply different formatting to different parts of a cell, you
+         need to use 
+         <a href="/apidocs/org/apache/poi/ss/usermodel/RichTextString.html">RichTextString</a>,
+         which permits styling of parts of the text within the cell.
+        </p>
+        
+<p>
+         There are some slight differences between HSSF and XSSF, especially
+         around font colours (the two formats store colours quite differently
+         internally), refer to the
+         <a href="/apidocs/org/apache/poi/hssf/usermodel/HSSFRichTextString.html">HSSF Rich Text String</a>
+         and
+         <a href="/apidocs/org/apache/poi/xssf/usermodel/XSSFRichTextString.html">XSSF Rich Text String</a>
+         javadocs for more details.
+        </p>
+      
     
 
 </div>

Modified: poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml?rev=1746586&r1=1746585&r2=1746586&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml (original)
+++ poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml Thu Jun  2 15:06:29 2016
@@ -76,6 +76,7 @@
                     <li><link href="#Hiding">Hiding and Un-Hiding Rows</link></li>
                     <li><link href="#CellProperties">Setting Cell Properties</link></li>
                     <li><link href="#PivotTable">Create a Pivot Table</link></li>
+                    <li><link href="#RichText">Cells with multiple styles</link></li>
                 </ul>
             </section>
             <section><title>Features</title>
@@ -2227,5 +2228,60 @@ the data to populate another drop down l
   pivotTable.addReportFilter(3);
         </source>
       </section>
+      <anchor id="RichText"/>
+      <section><title>Cells with multiple styles (Rich Text Strings)</title>
+        <p>
+         To apply a single set of text formatting (colour, style, font etc)
+         to a cell, you should create a 
+         <link href="/apidocs/org/apache/poi/ss/usermodel/CellStyle.html">CellStyle</link>
+         for the workbook, then apply to the cells.
+        </p>
+        <source>
+  // HSSF Example
+  HSSFCell hssfCell = row.createCell(idx);
+  //rich text consists of two runs
+  HSSFRichTextString richString = new HSSFRichTextString( "Hello, World!" );
+  richString.applyFont( 0, 6, font1 );
+  richString.applyFont( 6, 13, font2 );
+  hssfCell.setCellValue( richString );
+
+
+  // XSSF Example
+  XSSFCell cell = row.createCell(1);
+  XSSFRichTextString rt = new XSSFRichTextString("The quick brown fox");
+
+  XSSFFont font1 = wb.createFont();
+  font1.setBold(true);
+  font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
+  rt.applyFont(0, 10, font1);
+
+  XSSFFont font2 = wb.createFont();
+  font2.setItalic(true);
+  font2.setUnderline(XSSFFont.U_DOUBLE);
+  font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
+  rt.applyFont(10, 19, font2);
+
+  XSSFFont font3 = wb.createFont();
+  font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
+  rt.append(" Jumped over the lazy dog", font3);
+
+  cell.setCellValue(rt);
+        </source>
+        <p>
+         To apply different formatting to different parts of a cell, you
+         need to use 
+         <link href="/apidocs/org/apache/poi/ss/usermodel/RichTextString.html">RichTextString</link>,
+         which permits styling of parts of the text within the cell.
+        </p>
+        <p>
+         There are some slight differences between HSSF and XSSF, especially
+         around font colours (the two formats store colours quite differently
+         internally), refer to the
+         <link href="/apidocs/org/apache/poi/hssf/usermodel/HSSFRichTextString.html">HSSF Rich Text String</link>
+         and
+         <link href="/apidocs/org/apache/poi/xssf/usermodel/XSSFRichTextString.html">XSSF Rich Text String</link>
+         javadocs for more details.
+        </p>
+      </section>
     </body>
 </document>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org