mirror of https://github.com/apache/poi.git
Remove chart title
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1875978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7c3bbb0ed
commit
8e00a42767
|
@ -253,6 +253,9 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
|
|||
chart.setAutoTitleDeleted(CTBoolean.Factory.newInstance());
|
||||
}
|
||||
chart.getAutoTitleDeleted().setVal(deleted);
|
||||
if (deleted && chart.isSetTitle()) {
|
||||
chart.unsetTitle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,7 +324,15 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Remove the chart title.
|
||||
* @since POI 4.1.3
|
||||
*/
|
||||
public void removeTitle() {
|
||||
setAutoTitleDeleted(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or Add chart 3D view into chart
|
||||
*
|
||||
* @return this method will add 3D view
|
||||
|
|
|
@ -137,6 +137,7 @@ public class TestXSSFChartTitle {
|
|||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
|
||||
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
|
||||
assertNotNull(chart);
|
||||
assertNotNull(chart.getTitle());
|
||||
XSSFRichTextString originalTitle = chart.getTitleText();
|
||||
assertNotNull(originalTitle);
|
||||
final String myTitle = "My chart title";
|
||||
|
@ -154,6 +155,7 @@ public class TestXSSFChartTitle {
|
|||
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
|
||||
assertNotNull(chart);
|
||||
assertNull(chart.getTitleText());
|
||||
assertNull(chart.getTitle());
|
||||
final String myTitle = "My chart title";
|
||||
chart.setTitleText(myTitle);
|
||||
XSSFRichTextString queryTitle = chart.getTitleText();
|
||||
|
@ -176,4 +178,30 @@ public class TestXSSFChartTitle {
|
|||
wb.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingFromExistingChartNoTitle() throws IOException {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx");
|
||||
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
|
||||
assertNotNull(chart);
|
||||
assertNull(chart.getTitleText());
|
||||
assertNull(chart.getTitle());
|
||||
chart.removeTitle();
|
||||
assertNull(chart.getTitleText());
|
||||
assertNull(chart.getTitle());
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingFromExistingChartWithTitle() throws IOException {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
|
||||
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
|
||||
assertNotNull(chart);
|
||||
assertNotNull(chart.getTitleText());
|
||||
assertNotNull(chart.getTitle());
|
||||
chart.removeTitle();
|
||||
assertNull(chart.getTitleText());
|
||||
assertNull(chart.getTitle());
|
||||
wb.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue