@andrey.potapov,
I’ve run into another issue. The charts I’ve captured and inserted into the slide looks like its scaled somehow.
The code I’ve used is:
public virtual bool CopyExcelChartToSlide_Aspose(Workbook wkBook, string excelSheet, string chartName, Presentation slideDeck, int slideNumber, float horizCoord, float vertCoord)
{
bool RetVal = true;
string msg, FullChartName;
Worksheet WkSheet = null;
Aspose.Cells.Charts.ChartCollection AllExcelCharts = null;
Aspose.Cells.Charts.Chart ExcelChart = null;
//ExcelNS.Workbook WkBook = null;
ISlide NextSlide = null;
string Prefix = "\t";
const float ScaleFactor = 70;
try
{
//Get the Excel chart with the specified name
WkSheet = wkBook.Worksheets[excelSheet];
AllExcelCharts = wkBook.Worksheets[excelSheet].Charts;
ExcelChart = AllExcelCharts
.OfType<Aspose.Cells.Charts.Chart>()
.Where(p => p.Name.ToLower() == chartName.ToLower())
.FirstOrDefault();
//If the specified chart name exists, then attempt to copy it to the slide
//Get the slide whose index is specified
NextSlide = slideDeck.Slides[slideNumber - 1];
if (ExcelChart != null)
{
using (MemoryStream ImgStream = new MemoryStream())
{
Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions
{
ImageType = Aspose.Cells.Drawing.ImageType.OfficeCompatibleEmf,
VerticalResolution = 300,
HorizontalResolution = 300,
OnlyArea = true
};
ExcelChart.ToImage(ImgStream, opts);
if(!ImgStream.Equals(default(MemoryStream)))
{
ImgStream.Seek(0, SeekOrigin.Begin);
IPPImage InsertImg = slideDeck.Images.AddImage(ImgStream);
NextSlide.Shapes.AddPictureFrame(ShapeType.Rectangle, horizCoord * ScaleFactor, vertCoord * ScaleFactor, ExcelChart.ChartObject.Width * (ScaleFactor / 100), ExcelChart.ChartObject.Height * (ScaleFactor / 100), InsertImg);
}
else
{
RetVal = false;
msg = $"Failed to save the chart { chartName} to memory stream";
this.OnPPTEventOccurred(msg);
}
}
}
else
{
//Specified chart does not exist
RetVal = false;
msg = $"The chart {FullChartName} was not found";
this.OnPPTEventOccurred(msg);
}
}
catch (Exception ex)
{
msg = $"An error occurred while attempting to copy the chart {chartName} to the slidee #{slideNumber}\r\n"
+ $"Details: {ex.Message}";
this.OnPPTEventOccurred(msg);
}
return RetVal;
}
@JThomas98,
Thank you for your patience. I’ve performed some research and found that the issue is related to Aspose.Cells. I’ve moved this thread to Aspose.Cells forum. My colleagues will get back to you shortly. @amjad.sahi FYI
@JThomas98
By using sample files and the following test code for testing, we can reproduce the issue. Found that excel charts are scaled when converted to EMF images. Please refer to the attachment. chart.zip (3.2 KB)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-56645
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi @JThomas98
For this problem, we have optimized, part of the image file is as follows. 240906.zip (2.3 MB)
We solved the problem that the newline position was too different from Excel.
Since there is no fixed standard for the position of line breaks, and Excel may have some newline logic that we are not able to know. this revision is intended to be as Excel as possible. However, there may be individual cases where there may be a one-word difference in the position of line breaks.
Thank you for your feedback. The enhancement/fix will hopefully be included in the upcoming release of Aspose.Cells v24.9, which is scheduled for this week.
The issues you have found earlier (filed as CELLSNET-56645) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi
Hi, Aspose Team
Even though the issue with the text wrapping has stopped, the graph to the right of the text seems to overlap the percentage text that follows the graph. image.png (13.3 KB)
@JThomas98
We can reproduce the issue by testing on the latest version v24.9 using the following sample code. When converting chart to emf, it was found that the text and chart overlapped. Please refer to the attachment. chart.zip (3.6 KB)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-56761
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
We have already logged a ticket (CELLSNET-56761) for this issue and are currently investigating it. Please allow us some time to thoroughly evaluate the issue. We will provide you with an update as soon as we have more information.
@leoluo , I understand. I was asking because I had shared all these templates previously. Anyways, I’m glad its fixed. Looking forward to the new release. Thank you!
The issues you have found earlier (filed as CELLSNET-56761) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi
In almost every chart from ExecSumReport worksheet, you’d notice that there is a [+] symbol in the bar graph in the image Aspose cells captures. But this isn’t there in excel. There are cases where there is either a [+] or [-] symbol in the graph (I’ve attached a second template, template2, to show this occurrence). In these cases, both the [+] and [-] symbols are coming together. There should only be one of these symbols along with each bar. Another thing is that the symbols are supposed to be towards the end of the bar, not at the beginning.
In cases where there is no data for the year, excel shows a thin blue line even though there is no bar graph to be displayed. Where as in aspose, this thin blue line isn’t coming through.
For the charts in DetailReport worksheet, the font color should be white for the percentage values inside the graph. This is being rendered as black in the aspose version.
The shapes in the chart in QuadMap worksheet looks a little pixelated. This isn’t a big concern but I’d really appreciate if there’s something I can do to get a better quality.