I am converting charts in XLSX file opened with Aspose.Cells and converting to an image and importing into my DOCX file using Aspose.Words. When getting the chart collection and converting to a bitmap the dates at the bottom of the chart change into serial numbers.
Code Excerpt
//oLoadExcel is my Excel workbook loaded into Aspose.Cells.Workbook
// AsposeExportChart is defined below code excerpt
...
oLoadedExcel.AsposeExportChart(sec.ChartWorksheet, chartfilename, sec.ChartTitle);
System.Diagnostics.Trace.WriteLineIf(_bDebug, sec.ChartTitle + " exported.");
if (Convert.ToBoolean(ConfigurationManager.AppSettings["ImportChartFromFileToDocx"]))
{
//Aspose.Words.Document oChart = new Aspose.Words.Document(baseChartPath + @"\" + psTimeFolder + @"\" + sec.ChartTitle.Replace("'", string.Empty).Replace(@"\", string.Empty).Replace("/", string.Empty).Replace("&", string.Empty).Replace(" ", string.Empty) + "." + "docx");
Aspose.Words.Document oChart = new Aspose.Words.Document();
Aspose.Words.<span style="color: magenta;">DocumentBuilder</span> oChartBuilder = <span style="color: red;">new</span> Aspose.Words.<span style="color: magenta;">DocumentBuilder</span>(oChart);
System.Drawing.<span style="color: magenta;">Image</span> img2 = System.Drawing.<span style="color: magenta;">Image</span>.FromFile(chartfilename);
oChartBuilder.InsertImage(img2, Aspose.Words.<span style="color: magenta;">ConvertUtil</span>.PixelToPoint(img2.Width, img2.HorizontalResolution),
Aspose.Words.<span style="color: magenta;">ConvertUtil</span>.PixelToPoint(img2.Height, img2.VerticalResolution));
<span style="color: green;">// oChartBuilder.InsertImage(img2);</span>
oChartBuilder.Writeln();
<span style="color: red;">if</span> (psChartWorkSheet == <span style="color: magenta;">Constants</span>.<span style="color: magenta;">Worksheets</span>.RMACharts)
oChart.Save(baseChartPath + <span style="color: rgb(163, 21, 21);">@"\"</span> + psTimeFolder + <span style="color: rgb(163, 21, 21);">"\\chart"</span> + sec.ChartSectionVar.Replace(<span style="color: rgb(163, 21, 21);">"."</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">","</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">@"\"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"/"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"&"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">" "</span>, <span style="color: red;">string</span>.Empty) + <span style="color: rgb(163, 21, 21);">"."</span> + <span style="color: rgb(163, 21, 21);">"docx"</span>);
<span style="color: red;">else</span>
oChart.Save(baseChartPath + <span style="color: rgb(163, 21, 21);">@"\"</span> + psTimeFolder + <span style="color: rgb(163, 21, 21);">"\\chartFin"</span> + sec.ChartTitle.Replace(<span style="color: rgb(163, 21, 21);">"."</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">","</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">@"\"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"/"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"&"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">" "</span>, <span style="color: red;">string</span>.Empty) + <span style="color: rgb(163, 21, 21);">"."</span> + <span style="color: rgb(163, 21, 21);">"docx"</span>);
}</pre><pre style="background: white; color: black; font-family: Consolas;">...</pre><pre style="background: white; color: black; font-family: Consolas;">...</pre><pre style="background: white; color: black; font-family: Consolas;"><pre style="background: white; color: black; font-family: Consolas;"> <span style="color: red;">public</span> <span style="color: red;">void</span> AsposeExportChart(<span style="color: red;">string</span> sWorksheetName, <span style="color: red;">string</span> outputChartName, <span style="color: red;">string</span> chartTitle)
{
ECells.Charts.<span style="color: magenta;">ChartCollection</span> oChartCollection = wb.Worksheets[sWorksheetName].Charts;
<span style="color: red;">foreach</span> (ECells.Charts.<span style="color: magenta;">Chart</span> oChart <span style="color: red;">in</span> oChartCollection)
{
<span style="color: red;">if</span> (oChart.Title != <span style="color: red;">null</span> && oChart.Title.Text != <span style="color: red;">null</span>)
{
<span style="color: red;">if</span> (chartTitle.Replace(<span style="color: rgb(163, 21, 21);">"."</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">","</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">@"\"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"/"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"&"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">" "</span>, <span style="color: red;">string</span>.Empty) == oChart.Title.Text.Replace(<span style="color: rgb(163, 21, 21);">"."</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">","</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">@"\"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"/"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"&"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">"'"</span>, <span style="color: red;">string</span>.Empty).Replace(<span style="color: rgb(163, 21, 21);">" "</span>, <span style="color: red;">string</span>.Empty))
{
<span style="color: red;">try</span>
{
System.Drawing.<span style="color: magenta;">Bitmap</span> bitmap = oChart.ToImage();
bitmap.Save(outputChartName, System.Drawing.Imaging.<span style="color: magenta;">ImageFormat</span>.Png);
}
<span style="color: red;">catch</span> (<span style="color: magenta;">Exception</span> ee)
{
<span style="color: magenta;">Trace</span>.WriteLine(ee.Message);
<span style="color: magenta;">Trace</span>.WriteLine(ee.StackTrace);
}
}
}
}
}</pre><pre style="background: white; color: black; font-family: Consolas;"> </pre><pre style="background: white; color: black; font-family: Consolas;">How can change the import process so that the dates appear?</pre><pre style="background: white; color: black; font-family: Consolas;"> </pre><pre style="background: white; color: black; font-family: Consolas;">Thanks for any help,</pre><pre style="background: white; color: black; font-family: Consolas;">Bryan</pre></pre><pre style="background: white; color: black; font-family: Consolas;"> </pre>