use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project poi by apache.
the class TestXSSFChartTitle method testExistingChartNoTitle.
@Test
public void testExistingChartNoTitle() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx");
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
assertNotNull(chart);
assertNull(chart.getTitleText());
final String myTitle = "My chart title";
chart.setTitleText(myTitle);
XSSFRichTextString queryTitle = chart.getTitleText();
assertNotNull(queryTitle);
assertEquals(myTitle, queryTitle.toString());
wb.close();
}
use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project poi by apache.
the class TestXSSFChartTitle method testNewChart.
@Test
public void testNewChart() throws IOException {
Workbook wb = createWorkbookWithChart();
XSSFChart chart = getChartFromWorkbook(wb, "linechart");
assertNotNull(chart);
assertNull(chart.getTitleText());
final String myTitle = "My chart title";
chart.setTitleText(myTitle);
XSSFRichTextString queryTitle = chart.getTitleText();
assertNotNull(queryTitle);
assertEquals(myTitle, queryTitle.toString());
final String myTitleFormula = "1 & \" and \" & 2";
chart.setTitleFormula(myTitleFormula);
// setting formula should unset text, but since there is a formula, returns an empty string
assertEquals("", chart.getTitleText().toString());
String titleFormula = chart.getTitleFormula();
assertNotNull(titleFormula);
assertEquals(myTitleFormula, titleFormula);
wb.close();
}
Aggregations