public void NewBasicChartThenSetTitle()
{
string expected="Basic Chart";
SpreadsheetDocument doc = new SpreadsheetDocument();
doc.New();
Table table = new Table(doc, "tab1", "tab1");
for (int i = 1; i <= 1; i++)
{
for (int j = 1; j <= 6; j++)
{
Cell cell = table.CreateCell();
cell.OfficeValueType = "float";
Paragraph paragraph = new Paragraph(doc);
string text = (j + i - 1).ToString();
paragraph.TextContent.Add(new SimpleText(doc, text));
cell.Content.Add(paragraph);
cell.OfficeValueType = "string";
cell.OfficeValue = text;
table.InsertCellAt(i, j, cell);
}
}
Chart basicChart = ChartBuilder.CreateChart(table, ChartTypes.line, "A4:F8");
ChartTitle ct = new ChartTitle(basicChart);
//ct.InitTitle();
ct.SetTitle(expected);
Assert.AreEqual(expected, ((Paragraph)ct.Content[0]).TextContent[0].Text);
basicChart.ChartTitle = ct;
IContent chartTitleContent = null;
chartTitleContent=basicChart.Content.Find(o => o is ChartTitle);
if (chartTitleContent == null)
{
foreach (IContent iContent in basicChart.Content)
{
if (iContent is ChartTitle) chartTitleContent = iContent;
}
}
Assert.AreEqual(expected, ((Paragraph)((ChartTitle)chartTitleContent).Content[0]).TextContent[0].Text);
table.InsertChartAt("H2", basicChart);
doc.TableCollection.Add(table);
doc.SaveTo(Path.Combine(AARunMeFirstAndOnce.outPutFolder,"BasicChartWithTitlesetafterwards.ods"));
}