From 5f2951ebc64be8a0501ef35cf3c1647fc6ea2c84 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 4 Nov 2016 11:11:09 +0000 Subject: [PATCH] As requested on StackOverflow, expose on CellStyle QuotePrefix/123Prefix git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1768012 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/usermodel/HSSFCellStyle.java | 18 ++++++++++++++++++ .../apache/poi/ss/usermodel/CellStyle.java | 16 ++++++++++++++++ .../poi/xssf/usermodel/XSSFCellStyle.java | 19 ++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java index 0fd7cf2ade..542ee2210b 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java @@ -243,6 +243,24 @@ public final class HSSFCellStyle implements CellStyle { return _format.isLocked(); } + /** + * Turn on or off "Quote Prefix" or "123 Prefix" for the style, + * which is used to tell Excel that the thing which looks like + * a number or a formula shouldn't be treated as on. + */ + @Override + public void setQuotePrefixed(boolean quotePrefix) { + _format.set123Prefix(quotePrefix); + } + + /** + * Is "Quote Prefix" or "123 Prefix" enabled for the cell? + */ + @Override + public boolean getQuotePrefixed() { + return _format.get123Prefix(); + } + /** * set the type of horizontal alignment for the cell * @param align - the type of alignment diff --git a/src/java/org/apache/poi/ss/usermodel/CellStyle.java b/src/java/org/apache/poi/ss/usermodel/CellStyle.java index 1eab8dec19..d16619c4d8 100644 --- a/src/java/org/apache/poi/ss/usermodel/CellStyle.java +++ b/src/java/org/apache/poi/ss/usermodel/CellStyle.java @@ -397,6 +397,22 @@ public interface CellStyle { */ boolean getLocked(); + + /** + * Turn on or off "Quote Prefix" or "123 Prefix" for the style, + * which is used to tell Excel that the thing which looks like + * a number or a formula shouldn't be treated as on. + * Turning this on is somewhat (but not completely, see {@link IgnoredErrorType}) + * like prefixing the cell value with a ' in Excel + */ + void setQuotePrefixed(boolean quotePrefix); + + /** + * Is "Quote Prefix" or "123 Prefix" enabled for the cell? + * Having this on is somewhat (but not completely, see {@link IgnoredErrorType}) + * like prefixing the cell value with a ' in Excel + */ + boolean getQuotePrefixed(); /** * set the type of horizontal alignment for the cell diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java index 9eec21ec6f..6e66f9926c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java @@ -46,7 +46,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType; - /** * * High level representation of the the possible formatting information for the contents of the cells on a sheet in a @@ -655,6 +654,14 @@ public class XSSFCellStyle implements CellStyle { return _cellXf.getProtection().getLocked(); } + /** + * Is "Quote Prefix" or "123 Prefix" enabled for the cell? + */ + @Override + public boolean getQuotePrefixed() { + return _cellXf.getQuotePrefix(); + } + /** * Get the color to use for the right border * @@ -1255,6 +1262,16 @@ public class XSSFCellStyle implements CellStyle { } _cellXf.getProtection().setLocked(locked); } + + /** + * Turn on or off "Quote Prefix" or "123 Prefix" for the style, + * which is used to tell Excel that the thing which looks like + * a number or a formula shouldn't be treated as on. + */ + @Override + public void setQuotePrefixed(boolean quotePrefix) { + _cellXf.setQuotePrefix(quotePrefix); + } /** * Set the color to use for the right border -- 2.39.5