Search in sources :

Example 16 with XSSFRichTextString

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();
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) Test(org.junit.Test)

Example 17 with XSSFRichTextString

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();
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) Test(org.junit.Test)

Aggregations

XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)17 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)7 Workbook (org.apache.poi.ss.usermodel.Workbook)6 Test (org.junit.Test)5 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)4 Cell (org.apache.poi.ss.usermodel.Cell)3 Row (org.apache.poi.ss.usermodel.Row)3 FileOutputStream (java.io.FileOutputStream)2 CellStyle (org.apache.poi.ss.usermodel.CellStyle)2 CellType (org.apache.poi.ss.usermodel.CellType)2 Comment (org.apache.poi.ss.usermodel.Comment)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 XSSFClientAnchor (org.apache.poi.xssf.usermodel.XSSFClientAnchor)2 SAXException (org.xml.sax.SAXException)2 DataFormatException (com.cubrid.common.ui.cubrid.table.dialog.DataFormatException)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 OPCPackage (org.apache.poi.openxml4j.opc.OPCPackage)1 FormulaError (org.apache.poi.ss.usermodel.FormulaError)1 RichTextString (org.apache.poi.ss.usermodel.RichTextString)1