ASF Bugzilla – Attachment 33286 Details for
Bug 58633
[patch] Need to set multiple CellStyle properties at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Patch file
file_58633.txt (text/plain), 2.83 KB, created by
Mark Murphy
on 2015-11-22 02:00:18 UTC
(
hide
)
Description:
Patch file
Filename:
MIME Type:
Creator:
Mark Murphy
Created:
2015-11-22 02:00:18 UTC
Size:
2.83 KB
patch
obsolete
>Index: src/java/org/apache/poi/ss/util/CellUtil.java >=================================================================== >--- src/java/org/apache/poi/ss/util/CellUtil.java (revision 1715581) >+++ src/java/org/apache/poi/ss/util/CellUtil.java (working copy) >@@ -172,20 +172,18 @@ > /** > * This method attempt to find an already existing CellStyle 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 applies the propertyName and propertyValue to the style. This is necessary >- * because Excel has an upper limit on the number of Styles that it supports. >+ * new one, then it applies the properties to the style. This is necessary 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 properties A HashMap of properties to be added to a cell style. > *@param cell The cell that needs it's style changes > */ >- public static void setCellStyleProperty(Cell cell, Workbook workbook, String propertyName, >- Object propertyValue) { >+ public static void setCellStyleProperty(Cell cell, Workbook workbook, Map<String, Object> properties) { > CellStyle originalStyle = cell.getCellStyle(); > CellStyle newStyle = null; > Map<String, Object> values = getFormatProperties(originalStyle); >- values.put(propertyName, propertyValue); >+ values.putAll(properties); > > // index seems like what index the cellstyle is in the list of styles for a workbook. > // not good to compare on! >@@ -209,6 +207,24 @@ > cell.setCellStyle(newStyle); > } > >+ /** >+ * This method calls setCellStyleProperty(Cell, Workbook, Map<String, Object>) with a single >+ * property. If more than one property is to be set, it is better to call with a HashMap rather >+ * than a single property since each property added will search for a matching style and >+ * potentially create an unnecessary intermediate CellStyle. >+ * >+ *@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 >+ */ >+ public static void setCellStyleProperty(Cell cell, Workbook workbook, String propertyName, >+ Object propertyValue) { >+ Map<String, Object> values = new HashMap<String, Object>(); >+ values.put(propertyName, propertyValue); >+ setCellStyleProperty(cell, workbook, values); >+ } >+ > /** > * Returns a map containing the format properties of the given cell style. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 58633
:
33286
|
33288
|
33450
|
33453