}
int y = yOffset;
if (coordList.size() > 1) {
y += coordList.get(1);
}
final DataCell cellInfo = new DataCell(true, coordList);
cellInfo.setCoordinates(cell.getCoordinateList());
if (cell.getValue() != null) {
try {
cellInfo.setRawNumber(cell.getDoubleValue());
} catch (Exception e1) {
LOG.error("could not get double value", e1);
}
}
String cellValue = cell.getFormattedValue(); // First try to get a
// formatted value
if (cellValue == null || cellValue.equals("null")) { //$NON-NLS-1$
cellValue = ""; //$NON-NLS-1$
}
if (cellValue.length() < 1) {
final Object value = cell.getValue();
if (value == null || value.equals("null")) { //$NON-NLS-1$
cellValue = ""; //$NON-NLS-1$
} else {
try {
// TODO this needs to become query / execution specific
DecimalFormat myFormatter = new DecimalFormat(SaikuProperties.FORMATDEFAULTNUMBERFORMAT); //$NON-NLS-1$
DecimalFormatSymbols dfs = new DecimalFormatSymbols(SaikuProperties.LOCALE);
myFormatter.setDecimalFormatSymbols(dfs);
String output = myFormatter.format(cell.getValue());
cellValue = output;
} catch (Exception e) {
// TODO: handle exception
}
}
// the raw value
}
// Format string is relevant for Excel export
// xmla cells can throw an error on this
try {
String formatString = (String) cell.getPropertyValue(Property.StandardCellProperty.FORMAT_STRING);
if (formatString != null && !formatString.startsWith("|")) {
cellInfo.setFormatString(formatString);
} else {
formatString = formatString.substring(1, formatString.length());
cellInfo.setFormatString(formatString.substring(0, formatString.indexOf("|")));
}
} catch (Exception e) {
// we tried
}
Map<String, String> cellProperties = new HashMap<String, String>();
String val = Olap4jUtil.parseFormattedCellValue(cellValue, cellProperties);
if (!cellProperties.isEmpty()) {
cellInfo.setProperties(cellProperties);
}
cellInfo.setFormattedValue(val);
matrix.set(x, y, cellInfo);
}
return matrix;
}