return sb.toString();
}
private static void appendRangeRef( final StringBuilder _sb, final Range _range, final int _sheetIndex )
{
final CellIndex cellFrom = (CellIndex) _range.getTopLeft();
final CellIndex cellTo = (CellIndex) _range.getBottomRight();
if (_sheetIndex != cellFrom.getSheetIndex() || _sheetIndex != cellTo.getSheetIndex()) {
if (cellFrom.getSheetIndex() != cellTo.getSheetIndex()) {
final String fromSheetName = cellFrom.getSheet().getName();
final String toSheetName = cellTo.getSheet().getName();
final boolean quoted = needsQuotes( fromSheetName ) || needsQuotes( toSheetName );
if (quoted) _sb.append( QUOTE );
_sb.append( escapeSheetName( fromSheetName ) );
_sb.append( RANGE_SEPARATOR );
_sb.append( escapeSheetName( toSheetName ) );
if (quoted) _sb.append( QUOTE );
}
else {
final String sheetName = cellFrom.getSheet().getName();
final boolean quoted = needsQuotes( sheetName );
if (quoted) _sb.append( QUOTE );
_sb.append( escapeSheetName( sheetName ) );
if (quoted) _sb.append( QUOTE );
}
_sb.append( SHEET_NAME_SEPARATOR );
}
CellIndex.appendNameA1ForCellIndex( _sb, cellFrom );
if (cellFrom.getColumnIndex() != cellTo.getColumnIndex() ||
cellFrom.getRowIndex() != cellTo.getRowIndex()) {
_sb.append( RANGE_SEPARATOR );
CellIndex.appendNameA1ForCellIndex( _sb, cellTo );
}
}