You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2017/03/17 10:35:13 UTC
[Bug 60880] New: Missing: search for CellStyle
https://bz.apache.org/bugzilla/show_bug.cgi?id=60880
Bug ID: 60880
Summary: Missing: search for CellStyle
Product: POI
Version: 3.15-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: dollinger.florian@gmx.de
Target Milestone: ---
I am trying to copy the whole Style of some Cells from one Worksheet to
another.
At the moment I am using .cloneStyleFrom(), but this way a new Style is created
everytime - since there is no way to detect if the new Style already exists and
can be reused.
XSSFCellStyle newStyle = dstSheet.getWorkbook().createCellStyle();
// this creates a new style for every single cell, bad!
newStyle.cloneStyleFrom(oldCell.getCellStyle());
newCell.setCellStyle(newStyle);
should become something like:
XSSFCellStyle newStyle = null;
XSSFCellStyle exisiting =
dstSheet.getWorkbook().searchForCellStyle(oldCell.getCellStyle());
// returns the already existing style (if), or null
if(existing == null){
newStyle = dstSheet.getWorkbook().createCellStyle();
newStyle.cloneStyleFrom(oldCell.getCellStyle());
newCell.setCellStyle(newStyle);
} else {
newCell.setCellStyle(existing);
}
I'll give it a try to patch it, if somebody has a good idea - please let me
know!
---
Another Way would be to use CellUtil.setCellStyleProperties(), but it's not
working for not-indexed colors, fonts, ...
Also a CellUtil.getCellStyleProperties() function would be nice.
(But thats another issue, i will do that afterwards)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60880] Missing: search for CellStyle
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60880
dollinger.florian@gmx.de changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from dollinger.florian@gmx.de ---
By the way, the following would in fact work - but makes only sense within the
same Workbook!
for(int p = 0; p < dstSheet.getWorkbook().getNumCellStyles(); p++){
if(dstSheet.getWorkbook().getCellStyleAt(p).equals(newStyle))
System.out.println("exists");
}
Because
applyAlignment="1" borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0"
on workbook 1
and
applyAlignment="1" borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0"
on workbook 2
may be referencing different fills, fonts, ... (the same index does not mean it
is really the same on both workbooks)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60880] Missing: search for CellStyle
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60880
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60880] Missing: search for CellStyle
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60880
dollinger.florian@gmx.de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dollinger.florian@gmx.de
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org