Skip to content

Commit 39e102b

Browse files
Update Program.cs
1 parent c2be478 commit 39e102b

File tree

1 file changed

+3
-6
lines changed
  • Charts/Convert-chart-to-image-and-replace/.NET/Convert-chart-to-image-and-replace

1 file changed

+3
-6
lines changed

Charts/Convert-chart-to-image-and-replace/.NET/Convert-chart-to-image-and-replace/Program.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Syncfusion.DocIO;
1+
using Syncfusion.DocIO;
22
using Syncfusion.DocIO.DLS;
33
using Syncfusion.DocIORenderer;
44
using System.Collections.Generic;
@@ -17,9 +17,9 @@ static void Main(string[] args)
1717
using (WordDocument wordDocument = new WordDocument(fileStream, FormatType.Docx))
1818
{
1919
List<Entity> charts = wordDocument.FindAllItemsByProperty(EntityType.Chart, null, null);
20-
foreach (WChart entity in charts)
20+
for (int i=0; i<charts.Count; i++)
2121
{
22-
WChart chart = (WChart)entity;
22+
WChart chart = (WChart)charts[i];
2323
//Get owner paragraph of chart.
2424
WParagraph paragraph = chart.OwnerParagraph;
2525
//Get index of the chart in the paragraph.
@@ -40,8 +40,6 @@ static void Main(string[] args)
4040
//Add image to the paragraph at chart index.
4141
if (chartIndex < paragraph.ChildEntities.Count)
4242
paragraph.ChildEntities.Insert(chartIndex, picture);
43-
else
44-
paragraph.ChildEntities.Add(picture);
4543
//Remove chart from the paragraph.
4644
paragraph.ChildEntities.Remove(chart);
4745
}
@@ -59,4 +57,3 @@ static void Main(string[] args)
5957
}
6058
}
6159
}
62-

0 commit comments

Comments
 (0)