2004-04-09 09:05:39 -04:00
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
/* ====================================================================
|
2006-12-22 14:18:16 -05:00
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
|
|
|
|
2002-09-19 21:27:33 -04:00
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
package org.apache.poi.hssf.usermodel.contrib;
|
2002-09-19 21:27:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.beanutils.PropertyUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
2002-09-29 19:50:35 -04:00
|
|
|
import org.apache.commons.lang.exception.NestableException;
|
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2002-09-19 21:27:33 -04:00
|
|
|
/**
|
|
|
|
* Various utility functions that make working with a cells and rows easier. The various
|
|
|
|
* methods that deal with style's allow you to create your HSSFCellStyles as you need them.
|
|
|
|
* When you apply a style change to a cell, the code will attempt to see if a style already
|
|
|
|
* exists that meets your needs. If not, then it will create a new style. This is to prevent
|
|
|
|
* creating too many styles. there is an upper limit in Excel on the number of styles that
|
|
|
|
* can be supported.
|
|
|
|
*
|
|
|
|
*@author Eric Pugh epugh@upstate.com
|
|
|
|
*/
|
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
public class HSSFCellUtil
|
|
|
|
{
|
|
|
|
|
|
|
|
private static HashMap unicodeMappings = new HashMap();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a row from the spreadsheet, and create it if it doesn't exist.
|
|
|
|
*
|
|
|
|
*@param rowCounter The 0 based row number
|
|
|
|
*@param sheet The sheet that the row is part of.
|
|
|
|
*@return The row indicated by the rowCounter
|
|
|
|
*/
|
|
|
|
public static HSSFRow getRow( int rowCounter, HSSFSheet sheet )
|
|
|
|
{
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
HSSFRow row = sheet.getRow( rowCounter );
|
2002-09-29 19:50:35 -04:00
|
|
|
if ( row == null )
|
|
|
|
{
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
row = sheet.createRow( rowCounter );
|
2002-09-29 19:50:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return row;
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
2002-09-29 19:50:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
* Get a specific cell from a row. If the cell doesn't exist,
|
|
|
|
* then create it.
|
2002-09-29 19:50:35 -04:00
|
|
|
*
|
|
|
|
*@param row The row that the cell is part of
|
|
|
|
*@param column The column index that the cell is in.
|
|
|
|
*@return The cell indicated by the column.
|
|
|
|
*/
|
|
|
|
public static HSSFCell getCell( HSSFRow row, int column )
|
|
|
|
{
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
HSSFCell cell = row.getCell( column );
|
2002-09-29 19:50:35 -04:00
|
|
|
|
|
|
|
if ( cell == null )
|
|
|
|
{
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
cell = row.createCell( (short)column );
|
2002-09-29 19:50:35 -04:00
|
|
|
}
|
|
|
|
return cell;
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
2002-09-29 19:50:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a cell, gives it a value, and applies a style if provided
|
|
|
|
*
|
|
|
|
* @param row the row to create the cell in
|
|
|
|
* @param column the column index to create the cell in
|
|
|
|
* @param value The value of the cell
|
|
|
|
* @param style If the style is not null, then set
|
|
|
|
* @return A new HSSFCell
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static HSSFCell createCell( HSSFRow row, int column, String value, HSSFCellStyle style )
|
|
|
|
{
|
|
|
|
HSSFCell cell = getCell( row, column );
|
|
|
|
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
cell.setCellValue(new HSSFRichTextString(value));
|
2002-09-29 19:50:35 -04:00
|
|
|
if ( style != null )
|
|
|
|
{
|
|
|
|
cell.setCellStyle( style );
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
2002-09-19 21:27:33 -04:00
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
/**
|
|
|
|
* Create a cell, and give it a value.
|
|
|
|
*
|
|
|
|
*@param row the row to create the cell in
|
|
|
|
*@param column the column index to create the cell in
|
|
|
|
*@param value The value of the cell
|
|
|
|
*@return A new HSSFCell.
|
|
|
|
*/
|
|
|
|
public static HSSFCell createCell( HSSFRow row, int column, String value )
|
|
|
|
{
|
|
|
|
return createCell( row, column, value, null );
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
2002-09-29 19:50:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Take a cell, and align it.
|
|
|
|
*
|
|
|
|
*@param cell the cell to set the alignment for
|
|
|
|
*@param workbook The workbook that is being worked with.
|
|
|
|
*@param align the column alignment to use.
|
|
|
|
*@exception NestableException Thrown if an error happens.
|
2002-10-08 20:05:55 -04:00
|
|
|
*
|
|
|
|
* @see HSSFCellStyle for alignment options
|
2002-09-29 19:50:35 -04:00
|
|
|
*/
|
|
|
|
public static void setAlignment( HSSFCell cell, HSSFWorkbook workbook, short align ) throws NestableException
|
|
|
|
{
|
|
|
|
setCellStyleProperty( cell, workbook, "alignment", new Short( align ) );
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
/**
|
|
|
|
* Take a cell, and apply a font to it
|
|
|
|
*
|
|
|
|
*@param cell the cell to set the alignment for
|
|
|
|
*@param workbook The workbook that is being worked with.
|
|
|
|
*@param font The HSSFFont that you want to set...
|
|
|
|
*@exception NestableException Thrown if an error happens.
|
|
|
|
*/
|
|
|
|
public static void setFont( HSSFCell cell, HSSFWorkbook workbook, HSSFFont font ) throws NestableException
|
|
|
|
{
|
|
|
|
setCellStyleProperty( cell, workbook, "font", font );
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
/**
|
|
|
|
* This method attempt to find an already existing HSSFCellStyle that matches
|
|
|
|
* what you want the style to be. If it does not find the style, then it
|
|
|
|
* creates a new one. If it does create a new one, then it applyies the
|
|
|
|
* propertyName and propertyValue to the style. This is nessasary because
|
|
|
|
* Excel has an upper limit on the number of Styles that it supports.
|
|
|
|
*
|
|
|
|
*@param workbook The workbook that is being worked with.
|
|
|
|
*@param propertyName The name of the property that is to be
|
|
|
|
* changed.
|
|
|
|
*@param propertyValue The value of the property that is to be
|
|
|
|
* changed.
|
|
|
|
*@param cell The cell that needs it's style changes
|
|
|
|
*@exception NestableException Thrown if an error happens.
|
|
|
|
*/
|
|
|
|
public static void setCellStyleProperty( HSSFCell cell, HSSFWorkbook workbook, String propertyName, Object propertyValue )
|
|
|
|
throws NestableException
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
HSSFCellStyle originalStyle = cell.getCellStyle();
|
|
|
|
HSSFCellStyle newStyle = null;
|
|
|
|
Map values = PropertyUtils.describe( originalStyle );
|
|
|
|
values.put( propertyName, propertyValue );
|
|
|
|
values.remove( "index" );
|
|
|
|
|
|
|
|
// index seems like what index the cellstyle is in the list of styles for a workbook.
|
|
|
|
// not good to compare on!
|
|
|
|
short numberCellStyles = workbook.getNumCellStyles();
|
|
|
|
|
|
|
|
for ( short i = 0; i < numberCellStyles; i++ )
|
|
|
|
{
|
|
|
|
HSSFCellStyle wbStyle = workbook.getCellStyleAt( i );
|
|
|
|
Map wbStyleMap = PropertyUtils.describe( wbStyle );
|
|
|
|
wbStyleMap.remove( "index" );
|
|
|
|
|
|
|
|
if ( wbStyleMap.equals( values ) )
|
|
|
|
{
|
|
|
|
newStyle = wbStyle;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( newStyle == null )
|
|
|
|
{
|
|
|
|
newStyle = workbook.createCellStyle();
|
|
|
|
newStyle.setFont( workbook.getFontAt( originalStyle.getFontIndex() ) );
|
|
|
|
PropertyUtils.copyProperties( newStyle, originalStyle );
|
|
|
|
PropertyUtils.setProperty( newStyle, propertyName, propertyValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
cell.setCellStyle( newStyle );
|
|
|
|
}
|
|
|
|
catch ( Exception e )
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
2002-09-19 21:27:33 -04:00
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
throw new NestableException( "Couldn't setCellStyleProperty.", e );
|
|
|
|
}
|
2002-09-19 21:27:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-29 19:50:35 -04:00
|
|
|
/**
|
|
|
|
* Looks for text in the cell that should be unicode, like α and provides the
|
|
|
|
* unicode version of it.
|
|
|
|
*
|
|
|
|
*@param cell The cell to check for unicode values
|
|
|
|
*@return transalted to unicode
|
|
|
|
*/
|
|
|
|
public static HSSFCell translateUnicodeValues( HSSFCell cell )
|
|
|
|
{
|
|
|
|
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653831 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653815 | nick | 2008-05-06 16:37:45 +0100 (Tue, 06 May 2008) | 1 line
Improve JavaDocs about iterators and gaps
........
r653816 | nick | 2008-05-06 16:38:08 +0100 (Tue, 06 May 2008) | 1 line
Fix int -> short issues that no longer apply
........
r653831 | nick | 2008-05-06 17:38:34 +0100 (Tue, 06 May 2008) | 1 line
Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653835 13f79535-47bb-0310-9956-ffa450edef68
2008-05-06 12:48:48 -04:00
|
|
|
String s = cell.getRichStringCellValue().getString();
|
2002-09-29 19:50:35 -04:00
|
|
|
boolean foundUnicode = false;
|
|
|
|
|
|
|
|
for ( Iterator i = unicodeMappings.entrySet().iterator(); i.hasNext(); )
|
|
|
|
{
|
|
|
|
Map.Entry entry = (Map.Entry) i.next();
|
|
|
|
String key = (String) entry.getKey();
|
|
|
|
if ( s.toLowerCase().indexOf( key ) != -1 )
|
|
|
|
{
|
|
|
|
s = StringUtils.replace( s, key, "" + entry.getValue().toString() + "" );
|
|
|
|
foundUnicode = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( foundUnicode )
|
|
|
|
{
|
|
|
|
cell.setEncoding( HSSFCell.ENCODING_UTF_16 );
|
|
|
|
cell.setCellValue( s );
|
|
|
|
}
|
|
|
|
return cell;
|
|
|
|
}
|
2002-09-19 21:27:33 -04:00
|
|
|
|
2003-05-03 14:58:44 -04:00
|
|
|
|
|
|
|
static {
|
2002-12-11 14:17:10 -05:00
|
|
|
unicodeMappings.put( "α", "\u03B1" );
|
2003-05-03 14:58:44 -04:00
|
|
|
unicodeMappings.put( "β", "\u03B2" );
|
2002-12-11 14:17:10 -05:00
|
|
|
unicodeMappings.put( "γ", "\u03B3" );
|
2003-05-03 14:58:44 -04:00
|
|
|
unicodeMappings.put( "δ", "\u03B4" );
|
2002-12-11 14:17:10 -05:00
|
|
|
unicodeMappings.put( "ε", "\u03B5" );
|
2003-05-03 14:58:44 -04:00
|
|
|
unicodeMappings.put( "ζ", "\u03B6" );
|
|
|
|
unicodeMappings.put( "η", "\u03B7" );
|
2002-12-11 14:17:10 -05:00
|
|
|
unicodeMappings.put( "θ", "\u03B8" );
|
2003-05-03 14:58:44 -04:00
|
|
|
unicodeMappings.put( "ι", "\u03B9" );
|
|
|
|
unicodeMappings.put( "κ", "\u03BA" );
|
|
|
|
unicodeMappings.put( "λ", "\u03BB" );
|
|
|
|
unicodeMappings.put( "μ", "\u03BC" );
|
|
|
|
unicodeMappings.put( "ν", "\u03BD" );
|
|
|
|
unicodeMappings.put( "ξ", "\u03BE" );
|
|
|
|
unicodeMappings.put( "ο", "\u03BF" );
|
2002-09-29 19:50:35 -04:00
|
|
|
}
|
2002-09-19 21:27:33 -04:00
|
|
|
|
|
|
|
}
|