No Chart added in docx file

Hi,

I tried your first sample (see https://help.syncfusion.com/file-formats/docio/working-with-charts) to add a chart in a docx file. The docx file is generated but it is empty so no chart is added. 

Do you have a sample that works?

Best regards,

Vince


CODE:

'Creates a new Word document
Dim document As New WordDocument()
'Adds section to the document
Dim sec As IWSection = document.AddSection()
'Adds paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Creates and Appends chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(446, 270)
'Sets chart type
chart.ChartType = OfficeChartType.Pie
'Sets chart title
chart.ChartTitle = "Best Selling Products"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
'Sets data for chart
chart.ChartData.SetValue(1, 1, "")
chart.ChartData.SetValue(1, 2, "Sales")
chart.ChartData.SetValue(2, 1, "Phyllis Lapin")
chart.ChartData.SetValue(2, 2, 141.396)
chart.ChartData.SetValue(3, 1, "Stanley Hudson")
chart.ChartData.SetValue(3, 2, 80.368)
chart.ChartData.SetValue(4, 1, "Bernard Shah")
chart.ChartData.SetValue(4, 2, 71.155)
chart.ChartData.SetValue(5, 1, "Patricia Lincoln")
chart.ChartData.SetValue(5, 2, 47.234)
chart.ChartData.SetValue(6, 1, "Camembert Pierrot")
chart.ChartData.SetValue(6, 2, 46.825)
chart.ChartData.SetValue(7, 1, "Thomas Hardy")
chart.ChartData.SetValue(7, 2, 42.593)
chart.ChartData.SetValue(8, 1, "Hanna Moos")
chart.ChartData.SetValue(8, 2, 41.819)
chart.ChartData.SetValue(9, 1, "Alice Mutton")
chart.ChartData.SetValue(9, 2, 32.698)
chart.ChartData.SetValue(10, 1, "Christina Berglund")
chart.ChartData.SetValue(10, 2, 29.171)
chart.ChartData.SetValue(11, 1, "Elizabeth Lincoln")
chart.ChartData.SetValue(11, 2, 25.696)
'Creates a new chart series with the name “Sales”
Dim pieSeries As IOfficeChartSerie = chart.Series.Add("Sales")
pieSeries.Values = chart.ChartData(2, 2, 11, 2)
'Sets data label
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside
'Sets background color
chart.ChartArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.PlotArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Sets category labels
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData(2, 1, 11, 1)
'Saves the document
document.Save("Sample.docx", FormatType.Docx, FormatType.Docx, Response, HttpContentDisposition.Attachment)
'Closes the document
document.Close()


3 Replies

MR Manikandan Ravichandran Syncfusion Team March 4, 2020 07:26 AM UTC

Hi Vince,

Thank you for contacting Syncfusion support.

We have tried to reproduce the reported chart missing issue using the code example which is given in our UG documentation but it is working fine in our end. For your reference, we have attached the sample which is used at our end to reproduce the issue and it can be download from the following link.
https://www.syncfusion.com/downloads/support/forum/152109/ze/AspNetWebForms-459471680

If you still facing the issue means, kindly share the modified sample of above and output document generated at your end which will helpful for us to provide you the appropriate solution at the earliest

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran



VI Vince March 4, 2020 09:02 AM UTC

Hi Manikandan

Thanks for the reply.

Still I'm facing the same problem in my project. That means that an empty docx file is generated without the chart. For your information, docx files without charts but only with text are generated successful.

My project runs on jquery version 1.7.2 for each page while your example does not use jquery on page Default.aspx. I can not exclude jquery for the project so I'm not able to test your code as presented in your sample. Could jquery be the problem here?

Best regards,

Vince


MR Manikandan Ravichandran Syncfusion Team March 5, 2020 05:44 PM UTC

Hi Vince,

Thank you for your update.

We have tried to reproduce the reported issue with the given details. But we are facing some difficulties to replicate the sample with the given details. So, kindly share the complete runnable sample to reproduce the issue which will helpful for us to provide you the appropriate solution at the earliest

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran


Loader.
Up arrow icon