You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2008/11/06 11:50:06 UTC
svn commit: r711839 - in /poi/branches/ooxml: ./
src/examples/src/org/apache/poi/ss/
src/examples/src/org/apache/poi/xssf/usermodel/examples/
src/ooxml/java/org/apache/poi/xssf/usermodel/
src/ooxml/testcases/org/apache/poi/xssf/usermodel/
Author: yegor
Date: Thu Nov 6 02:49:51 2008
New Revision: 711839
URL: http://svn.apache.org/viewvc?rev=711839&view=rev
Log:
1. included ooxml javadocs in build.xml2. added a new rich example: BusinessPlan.java3. misc bug fixes
Removed:
poi/branches/ooxml/src/examples/src/org/apache/poi/ss/
Modified:
poi/branches/ooxml/build.xml
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoanCalculator.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/TimesheetDemo.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
Modified: poi/branches/ooxml/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/build.xml?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/build.xml (original)
+++ poi/branches/ooxml/build.xml Thu Nov 6 02:49:51 2008
@@ -1000,7 +1000,7 @@
<packageset dir="${contrib.src}" defaultexcludes="yes">
<include name="org/apache/poi/**"/>
</packageset>
- <packageset dir="${examples.src}" defaultexcludes="yes">
+ <packageset dir="${ooxml.src}" defaultexcludes="yes">
<include name="org/apache/poi/**"/>
</packageset>
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java Thu Nov 6 02:49:51 2008
@@ -28,7 +28,7 @@
public class AligningCells {
public static void main(String[] args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow((short) 2);
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java Thu Nov 6 02:49:51 2008
@@ -128,7 +128,7 @@
/**
* cell styles used for formatting calendar sheets
*/
- public static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
+ private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
XSSFCellStyle style;
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java Thu Nov 6 02:49:51 2008
@@ -31,7 +31,7 @@
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
CreationHelper creationHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java Thu Nov 6 02:49:51 2008
@@ -34,7 +34,7 @@
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("format sheet");
CellStyle style;
DataFormat format = wb.createDataFormat();
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java Thu Nov 6 02:49:51 2008
@@ -28,7 +28,7 @@
*/
public class FillsAndColors {
public static void main(String[] args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java Thu Nov 6 02:49:51 2008
@@ -27,7 +27,7 @@
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("format sheet");
PrintSetup ps = sheet.getPrintSetup();
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java Thu Nov 6 02:49:51 2008
@@ -29,7 +29,7 @@
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("first-header - format sheet");
sheet.createRow(0).createCell(0).setCellValue(123);
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java Thu Nov 6 02:49:51 2008
@@ -29,7 +29,7 @@
public static void main(String[]args) throws Exception{
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
//cell style for hyperlinks
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoanCalculator.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoanCalculator.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoanCalculator.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoanCalculator.java Thu Nov 6 02:49:51 2008
@@ -138,7 +138,7 @@
/**
* cell styles used for formatting calendar sheets
*/
- public static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
+ private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
XSSFCellStyle style;
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java Thu Nov 6 02:49:51 2008
@@ -32,7 +32,7 @@
*/
public class MergingCells {
public static void main(String[] args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
Row row = sheet.createRow((short) 1);
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java Thu Nov 6 02:49:51 2008
@@ -31,7 +31,7 @@
public class NewLinesInCells {
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(2);
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java Thu Nov 6 02:49:51 2008
@@ -26,7 +26,7 @@
public class SelectedSheet {
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("row sheet");
Sheet sheet2 = wb.createSheet("another sheet");
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java Thu Nov 6 02:49:51 2008
@@ -30,7 +30,7 @@
public class ShiftRows {
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("Sheet1");
Row row1 = sheet.createRow(1);
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/TimesheetDemo.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/TimesheetDemo.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/TimesheetDemo.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/TimesheetDemo.java Thu Nov 6 02:49:51 2008
@@ -149,7 +149,7 @@
out.close();
}
- public static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
+ private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
XSSFCellStyle style;
XSSFFont titleFont = wb.createFont();
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java Thu Nov 6 02:49:51 2008
@@ -27,7 +27,7 @@
*/
public class WorkingWithBorders {
public static void main(String[] args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("borders");
// Create a row and put some cells in it. Rows are 0 based.
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java Thu Nov 6 02:49:51 2008
@@ -27,7 +27,7 @@
*/
public class WorkingWithFonts {
public static void main(String[] args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("Fonts");
Font font0 = wb.createFont();
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java Thu Nov 6 02:49:51 2008
@@ -29,7 +29,7 @@
public class WorkingWithPageSetup {
public static void main(String[]args) throws Exception {
- Workbook wb = new XSSFWorkbook();
+ Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
/**
* It's possible to set up repeating rows and columns in your printouts by using the setRepeatingRowsAndColumns() function in the Workbook object.
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java Thu Nov 6 02:49:51 2008
@@ -32,7 +32,7 @@
public static void main(String[] args) throws IOException {
//create a new workbook
- XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
//add a picture in this workbook.
InputStream is = new FileInputStream("lilies.jpg");
Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java Thu Nov 6 02:49:51 2008
@@ -17,7 +17,6 @@
package org.apache.poi.xssf.usermodel.examples;
import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.usermodel.*;
import java.io.FileOutputStream;
@@ -27,30 +26,36 @@
public class WorkingWithRichText {
public static void main(String[] args) throws Exception {
-
- XSSFWorkbook wb = new XSSFWorkbook();
+
+ XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow((short) 2);
XSSFCell cell = row.createCell(1);
- XSSFRichTextString rt = new XSSFRichTextString("The quick");
+ XSSFRichTextString rt = new XSSFRichTextString("The quick brown fox");
XSSFFont font1 = wb.createFont();
font1.setBold(true);
- rt.append(" brown fox", font1);
+ font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
+ rt.applyFont(0, 10, font1);
XSSFFont font2 = wb.createFont();
font2.setItalic(true);
- font2.setColor(IndexedColors.RED.getIndex());
- rt.applyFont((short) 0);
+ 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);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("xssf-richtext.xlsx");
wb.write(fileOut);
fileOut.close();
-
}
}
Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java Thu Nov 6 02:49:51 2008
@@ -31,7 +31,9 @@
* Creates a new XSSFRichTextString for you.
*/
public XSSFRichTextString createRichTextString(String text) {
- return new XSSFRichTextString(text);
+ XSSFRichTextString rt =new XSSFRichTextString(text);
+ rt.setStylesTableReference(workbook.getStylesSource());
+ return rt;
}
public XSSFDataFormat createDataFormat() {
Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java Thu Nov 6 02:49:51 2008
@@ -68,7 +68,6 @@
public class XSSFRichTextString implements RichTextString {
private CTRst st;
private StylesTable styles;
- private ArrayList<CTRPrElt> fontIdRuns;
/**
* Create a rich text string and initialize it with empty string
@@ -106,7 +105,6 @@
//when setStylesTableReference is called
font = new XSSFFont();
font.setFontName("#" + fontIndex);
- fontIdRuns = new ArrayList<CTRPrElt>();
} else {
font = styles.getFontAt(fontIndex);
}
@@ -139,50 +137,50 @@
XSSFFont xssfFont = (XSSFFont)font;
ArrayList<CTRElt> runs = new ArrayList<CTRElt>();
+ CTRElt[] r = st.getRArray();
int pos = 0;
- int i;
- for (i = 0; i < st.sizeOfRArray(); i++) {
- CTRElt r = st.getRArray(i);
-
- int len = r.getT().length();
- int p1 = pos;
- int p2 = pos + len;
- if(startIndex > p2) {
- runs.add(r);
- } else if (startIndex >= p1 && startIndex < p2){
- String t = r.getT();
- r.setT(t.substring(0, startIndex-p1));
- runs.add(r);
+ for (int i = 0; i < r.length; i++) {
+ int rStart = pos;
+ String t = r[i].getT();
+ int rEnd = rStart + t.length();
+
+ if(rEnd <= startIndex) {
+ runs.add(r[i]);
+ pos += r[i].getT().length();
+ }
+ else if (startIndex > rStart && startIndex < rEnd){
+ CTRElt c = (CTRElt)r[i].copy();
+ String txt = text.substring(rStart, startIndex);
+ c.setT(txt);
+ runs.add(c);
+ pos += txt.length();
} else {
break;
}
- pos = p2;
}
- CTRElt r = CTRElt.Factory.newInstance();
- r.setT(text.substring(startIndex, endIndex));
- CTRPrElt pr = r.addNewRPr();
+ CTRElt rt = CTRElt.Factory.newInstance();
+ String txt = text.substring(startIndex, endIndex);
+ rt.setT(txt);
+ CTRPrElt pr = rt.addNewRPr();
setRunAttributes(xssfFont.getCTFont(), pr);
- if(fontIdRuns != null) fontIdRuns.add(pr);
- runs.add(r);
+ runs.add(rt);
+ pos += txt.length();
- for (; i < st.sizeOfRArray(); i++) {
- r = st.getRArray(i);
-
- int len = r.getT().length();
- int p1 = pos;
- int p2 = pos + len;
- if(endIndex > p2) {
- ;
- } else if (endIndex >= p1 && endIndex < p2){
- String t = r.getT();
- r.setT(t.substring(endIndex-p1, len));
- runs.add(r);
- } else {
- runs.add(r);
+ for (int i = 0; i < r.length; i++) {
+ int rStart = pos;
+ String t = r[i].getT();
+ int rEnd = Math.min(rStart + t.length(), text.length());
+
+ if (endIndex < rEnd){
+ CTRElt c = (CTRElt)r[i].copy();
+ txt = text.substring(rStart, rEnd);
+ c.setT(txt);
+ runs.add(c);
+ pos += txt.length();
}
- pos = p2;
}
+
st.setRArray(runs.toArray(new CTRElt[runs.size()]));
}
@@ -202,9 +200,6 @@
setRunAttributes(((XSSFFont)font).getCTFont(), r.addNewRPr());
st.setRArray(new CTRElt[]{r});
}
-
- if(fontIdRuns != null) fontIdRuns.add(st.getRArray(0).getRPr());
-
}
/**
@@ -217,7 +212,6 @@
if(styles == null) {
font = new XSSFFont();
font.setFontName("#" + fontIndex);
- fontIdRuns = new ArrayList<CTRPrElt>();
} else {
font = styles.getFontAt(fontIndex);
}
@@ -240,8 +234,6 @@
lt.setT(text);
CTRPrElt pr = lt.addNewRPr();
if(font != null) setRunAttributes(font.getCTFont(), pr);
-
- if(fontIdRuns != null) fontIdRuns.add(pr);
}
/**
@@ -419,9 +411,10 @@
protected void setStylesTableReference(StylesTable tbl){
styles = tbl;
- if(fontIdRuns != null){
- for (CTRPrElt pr : fontIdRuns) {
- if(pr.sizeOfRFontArray() > 0 ) {
+ if(st.sizeOfRArray() > 0) {
+ for (CTRElt r : st.getRArray()) {
+ CTRPrElt pr = r.getRPr();
+ if(pr != null){
String fontName = pr.getRFontArray(0).getVal();
if(fontName.startsWith("#")){
int idx = Integer.parseInt(fontName.substring(1));
Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Thu Nov 6 02:49:51 2008
@@ -332,7 +332,7 @@
pane.setTopLeftCell(new CellReference(0, topRow).formatAsString());
pane.setActivePane(STPane.TOP_RIGHT);
} else if (colSplit == 0) {
- pane.setTopLeftCell(new CellReference(leftmostColumn, 64).formatAsString());
+ pane.setTopLeftCell(new CellReference(rowSplit, 0).formatAsString());
pane.setActivePane(STPane.BOTTOM_LEFT);
} else {
pane.setTopLeftCell(new CellReference(leftmostColumn, topRow).formatAsString());
Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java Thu Nov 6 02:49:51 2008
@@ -28,11 +28,10 @@
// Create a new workbook
XSSFWorkbook wb = new XSSFWorkbook();
-
- // Create a worksheet 'sheet1' in the new workbook
XSSFName name1 = wb.createName();
name1.setNameName("testOne");
+ //setting a duplicate name should throw IllegalArgumentException
XSSFName name2 = wb.createName();
try {
name2.setNameName("testOne");
Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java?rev=711839&r1=711838&r2=711839&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java Thu Nov 6 02:49:51 2008
@@ -71,7 +71,7 @@
rt.applyFont(2, 5, font1);
- assertEquals(4, rt.numFormattingRuns());
+ assertEquals(5, rt.numFormattingRuns());
assertEquals(0, rt.getIndexOfFormattingRun(0));
assertEquals(2, rt.getLengthOfFormattingRun(0));
@@ -79,10 +79,10 @@
assertEquals(3, rt.getLengthOfFormattingRun(1));
assertEquals(5, rt.getIndexOfFormattingRun(2));
- assertEquals(2, rt.getLengthOfFormattingRun(2));
+ assertEquals(3, rt.getLengthOfFormattingRun(2));
- assertEquals(7, rt.getIndexOfFormattingRun(3));
- assertEquals(2, rt.getLengthOfFormattingRun(3));
+ assertEquals(8, rt.getIndexOfFormattingRun(3));
+ assertEquals(1, rt.getLengthOfFormattingRun(3));
}
public void testClearFormatting() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org