// ZSS-568 private boolean processTopBorder( StringBuffer sb, StringBuffer db, SCellStyle fillStyle, SCellStyle tbStyle) { // ZSS-977 boolean hitTop = false; MergedRect rect = null; boolean hitMerge = false; // ZSS-259: should apply the top border from the cell of merged range's top // as processRightBorder() does. rect = _mmHelper.getMergeRange(_row, _col); int top = _row; if (rect != null) { hitMerge = true; top = rect.getRow(); } SCellStyle nextStyle = StyleUtil.getTopStyle(_sheet.getCell(top, _col).getCellStyle(), tbStyle); // ZSS-977 if (nextStyle != null) { BorderType bb = nextStyle.getBorderTop(); if (bb == BorderType.DOUBLE) { String color = nextStyle.getBorderTopColor().getHtmlColor(); hitTop = appendBorderStyle(sb, "top", bb, color); } else if (bb != BorderType.NONE) { // ZSS-919: check if my top is a merged cell top = hitMerge ? rect.getRow() - 1 : _row - 1; if (top >= 0) { final MergedRect rectT = _mmHelper.getMergeRange(top, _col); // my top merge more than 2 columns if (rectT != null && rectT.getColumn() < rectT.getLastColumn()) { String color = nextStyle.getBorderTopColor().getHtmlColor(); // support only solid line but position correctly return appendMergedBorder(sb, "top", color); // //offset 1px to bottom but support more line styles // return hitTop = appendBorderStyle(sb, "top", bb, color); } } } } // ZSS-259: should check and apply the bottom border from the top cell // of merged range's top as processRightBorder() does. if (!hitTop) { top = hitMerge ? rect.getRow() - 1 : _row - 1; if (top >= 0) { nextStyle = _sheet.getCell(top, _col).getCellStyle(); // ZSS-977 if (nextStyle.getBorderBottom() == BorderType.NONE) { final STable table0 = ((AbstractSheetAdv) _sheet).getTableByRowCol(top, _col); final SCellStyle tbStyle0 = table0 == null ? null : ((AbstractTableAdv) table0).getCellStyle(top, _col); nextStyle = StyleUtil.getBottomStyle(nextStyle, tbStyle0); } if (nextStyle != null) { BorderType bb = nextStyle.getBorderBottom(); // get bottom border of if (bb == BorderType.DOUBLE) { String color = nextStyle.getBorderBottomColor().getHtmlColor(); // set next row top border as cell's top border; hitTop = appendBorderStyle(sb, "top", bb, color); } } } } db.append(hitTop ? "t" : "_"); return hitTop; }
private boolean processLeftBorder( StringBuffer sb, StringBuffer db, SCellStyle fillStyle, SCellStyle tbStyle) { // ZSS-977 boolean hitLeft = false; MergedRect rect = null; boolean hitMerge = false; // find left border of target cell rect = _mmHelper.getMergeRange(_row, _col); int left = _col; if (rect != null) { hitMerge = true; left = rect.getColumn(); } SCellStyle nextStyle = StyleUtil.getLeftStyle(_sheet.getCell(_row, left).getCellStyle(), tbStyle); // ZSS-977 if (nextStyle != null) { BorderType bb = nextStyle.getBorderLeft(); if (bb == BorderType.DOUBLE) { String color = nextStyle.getBorderLeftColor().getHtmlColor(); hitLeft = appendBorderStyle(sb, "left", bb, color); } else if (bb != BorderType.NONE) { // ZSS-919: check if my left is a merged cell left = hitMerge ? rect.getColumn() - 1 : _col - 1; if (left >= 0) { final MergedRect rectT = _mmHelper.getMergeRange(_row, left); // my left merged more than 2 rows if (rectT != null && rectT.getRow() < rectT.getLastRow()) { String color = nextStyle.getBorderLeftColor().getHtmlColor(); // support only solid line but position correctly return appendMergedBorder(sb, "left", color); // //offset 1px to right but support more line styles // return hitLeft = appendBorderStyle(sb, "left", bb, color); } } } } // if no border for target cell,then check if this cell is in a merge range // if(true) then try to get next cell after this merge range // else get next cell of this cell if (!hitLeft) { left = hitMerge ? rect.getColumn() - 1 : _col - 1; if (left >= 0) { nextStyle = _sheet.getCell(_row, left).getCellStyle(); // ZSS-977 if (nextStyle.getBorderRight() == BorderType.NONE) { final STable table0 = ((AbstractSheetAdv) _sheet).getTableByRowCol(_row, left); final SCellStyle tbStyle0 = table0 == null ? null : ((AbstractTableAdv) table0).getCellStyle(_row, left); nextStyle = StyleUtil.getRightStyle(nextStyle, tbStyle0); } if (nextStyle != null) { BorderType bb = nextStyle.getBorderRight(); // get right here // String color = BookHelper.indexToRGB(_book, style.getLeftBorderColor()); // ZSS-34 cell background color does not show in excel if (bb == BorderType.DOUBLE) { String color = nextStyle.getBorderRightColor().getHtmlColor(); hitLeft = appendBorderStyle(sb, "left", bb, color); } } } } db.append(hitLeft ? "l" : "_"); return hitLeft; }
private boolean processBottomBorder( StringBuffer sb, StringBuffer db, SCellStyle fillStyle, SCellStyle tbStyle) { // ZSS-977 boolean hitBottom = false; MergedRect rect = null; boolean hitMerge = false; // ZSS-259: should apply the bottom border from the cell of merged range's bottom // as processRightBorder() does. rect = _mmHelper.getMergeRange(_row, _col); int bottom = _row; if (rect != null) { hitMerge = true; bottom = rect.getLastRow(); } SCellStyle nextStyle = StyleUtil.getBottomStyle(_sheet.getCell(bottom, _col).getCellStyle(), tbStyle); // ZSS-977 BorderType bb = null; if (nextStyle != null) { bb = nextStyle.getBorderBottom(); String color = nextStyle.getBorderBottomColor().getHtmlColor(); hitBottom = appendBorderStyle(sb, "bottom", bb, color); } // ZSS-259: should check and apply the top border from the bottom cell // of merged range's bottom as processRightBorder() does. SCellStyle nextFillStyle = null; // ZSS-977 if (!hitBottom) { bottom = hitMerge ? rect.getLastRow() + 1 : _row + 1; /*if(next == null){ // don't search into merge ranges //check is _row+1,_col in merge range MergedRect rect = _mmHelper.getMergeRange(_row+1, _col); if(rect !=null){ next = _sheet.getCell(rect.getTop(),rect.getLeft()); } }*/ // ZSS-919: merge more than 2 columns; must use top border of bottom cell if (!hitMerge || rect.getColumn() == rect.getLastColumn()) { nextFillStyle = nextStyle = _sheet.getCell(bottom, _col).getCellStyle(); // ZSS-977 SCellStyle nextTbStyle = null; if (nextStyle.getBorderTop() == BorderType.NONE) { final STable table0 = ((AbstractSheetAdv) _sheet).getTableByRowCol(bottom, _col); nextTbStyle = table0 == null ? null : ((AbstractTableAdv) table0).getCellStyle(bottom, _col); nextStyle = StyleUtil.getTopStyle(nextStyle, nextTbStyle); } if (nextStyle != null) { bb = nextStyle.getBorderTop(); // get top border of String color = nextStyle.getBorderTopColor().getHtmlColor(); // set next row top border as cell's bottom border; hitBottom = appendBorderStyle(sb, "bottom", bb, color); } // ZSS-977 if (!hitBottom) { nextFillStyle = StyleUtil.getFillStyle(nextFillStyle, nextTbStyle); } } } // border depends on next cell's fill color if solid pattern if (!hitBottom && nextFillStyle != null) { // String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor()); // ZSS-34 cell background color does not show in excel String bgColor = nextFillStyle.getFillPattern() == FillPattern.SOLID ? nextFillStyle.getBackColor().getHtmlColor() : null; // ZSS-857 if (bgColor != null) { hitBottom = appendBorderStyle(sb, "bottom", BorderType.THIN, bgColor); } else if (nextFillStyle.getFillPattern() != FillPattern.NONE) { // ZSS-841 sb.append("border-bottom:none;"); // no grid line either hitBottom = true; } } // border depends on current cell's background color if (!hitBottom && fillStyle != null) { // String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor()); // ZSS-34 cell background color does not show in excel String bgColor = fillStyle.getFillPattern() == FillPattern.SOLID ? fillStyle.getBackColor().getHtmlColor() : null; if (bgColor != null) { hitBottom = appendBorderStyle(sb, "bottom", BorderType.THIN, bgColor); } else if (fillStyle.getFillPattern() != FillPattern.NONE) { // ZSS-841 sb.append("border-bottom:none;"); // no grid line either hitBottom = true; } } db.append(hitBottom && bb == BorderType.DOUBLE ? "b" : "_"); return hitBottom; }