ARTICLE AD BOX
I'm trying to insert a chart in a Word document and found NPOI with an example, but the example is just adding the chart without adding data.
When I try to merge some code coming from XSSF part it gives this code:
XWPFDocument doc = new XWPFDocument(); XWPFParagraph p1 = doc.CreateParagraph(); p1.Alignment = ParagraphAlignment.CENTER; XWPFRun r1 = p1.CreateRun(); r1.SetText("Hello NPOI Word"); r1.FontSize = 20; r1.IsBold = true; XWPFChart ch = doc.CreateChart(r1, 100, 100); var bottomAxis = ch.CreateCategoryAxis(NPOI.XDDF.UserModel.Chart.AxisPosition.Bottom); var leftAxis = ch.CreateValueAxis(NPOI.XDDF.UserModel.Chart.AxisPosition.Left); var barCharData = ch.CreateData<string, double>(NPOI.XDDF.UserModel.Chart.ChartTypes.BAR, bottomAxis, leftAxis) as XDDFBarChartData<string, double>; ch.Plot(barCharData); ch.SetTitleText("TITRE"); using (FileStream fs = File.Create("text.docx")) { doc.Write(fs); }The program crashes on the last line giving me this error:

