use of org.apache.poi.hssf.usermodel.HSSFRichTextString in project poi by apache.
the class NumberRenderingSpreadsheetGenerator method writeDataRow.
static void writeDataRow(HSSFSheet sheet, int rowIx, long rawLongBits, String expectedExcelRendering) {
double d = Double.longBitsToDouble(rawLongBits);
HSSFRow row = sheet.createRow(rowIx);
int rowNum = rowIx + 1;
String cel0ref = "A" + rowNum;
String rawBitsText = formatLongAsHex(rawLongBits);
String jmExpr = "'ec(" + rawBitsText + ", ''\" & C" + rowNum + " & \"'', ''\" & D" + rowNum + " & \"''),'";
// The 'Match' column will contain 'OK' if the metadata (from NumberToTextConversionExamples)
// matches Excel's rendering.
String matchExpr = "if(D" + rowNum + "=E" + rowNum + ", \"OK\", \"ERROR\")";
row.createCell(0).setCellValue(d);
row.createCell(1).setCellValue(new HSSFRichTextString(rawBitsText));
row.createCell(2).setCellValue(new HSSFRichTextString(Double.toString(d)));
row.createCell(3).setCellFormula("\"\" & " + cel0ref);
row.createCell(4).setCellValue(new HSSFRichTextString(expectedExcelRendering));
row.createCell(5).setCellFormula(matchExpr);
row.createCell(6).setCellFormula(jmExpr.replaceAll("'", "\""));
// if (false) {
// // for observing arithmetic near numeric range boundaries
// row.createCell(7).setCellFormula(cel0ref + " * 1.0001");
// row.createCell(8).setCellFormula(cel0ref + " / 1.0001");
// }
}
use of org.apache.poi.hssf.usermodel.HSSFRichTextString in project poi by apache.
the class TestDrawingShapes method testRotation.
@Test
public void testRotation() throws IOException {
HSSFWorkbook wb1 = new HSSFWorkbook();
HSSFSheet sheet = wb1.createSheet();
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFSimpleShape rectangle = patriarch.createSimpleShape(new HSSFClientAnchor(0, 0, 100, 100, (short) 0, 0, (short) 5, 5));
rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
assertEquals(rectangle.getRotationDegree(), 0);
rectangle.setRotationDegree((short) 45);
assertEquals(rectangle.getRotationDegree(), 45);
rectangle.setFlipHorizontal(true);
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
wb1.close();
sheet = wb2.getSheetAt(0);
patriarch = sheet.getDrawingPatriarch();
rectangle = (HSSFSimpleShape) patriarch.getChildren().get(0);
assertEquals(rectangle.getRotationDegree(), 45);
rectangle.setRotationDegree((short) 30);
assertEquals(rectangle.getRotationDegree(), 30);
patriarch.setCoordinates(0, 0, 10, 10);
rectangle.setString(new HSSFRichTextString("1234"));
wb2.close();
}
use of org.apache.poi.hssf.usermodel.HSSFRichTextString in project processdash by dtuma.
the class WBSExcelWriter method writeCellForNodeName.
private void writeCellForNodeName(WBSNode node, HSSFRow row) {
HSSFCell cell = row.createCell(s(0));
String name = node.getName();
if (name == null || name.trim().length() == 0)
name = "(empty)";
cell.setCellValue(new HSSFRichTextString(name));
StyleKey style = new StyleKey();
style.indent = s(node.getIndentLevel());
if (WBSModelValidator.hasNodeError(node)) {
style.setColor(Color.RED);
style.bold = true;
}
styleCache.applyStyle(cell, style);
}
Aggregations