Tryin to update Aspose release version from 22.1.0 to 23.5.0 but some of my drawings are getting messed with the latest version when nothings been changed to the source code.
Issues:
Whenever making edits to an OLE Object and saving it back to visio, the image resize gets messed up or just show a box crossed out. I been having this resize issue in version 22.1.0. To get OLE back to it’s previous size, I would have to manually double-click the OLE Object in visio to open the table and then exit out. The examples I’ve provided, the resize aren’t too terrible but I’ve had others that are so small the text aren’t readable.
As for getting the crossed out box instead of a messed up table size, this is new when updated to 23.5.0, it’s hard for me to replicate it in a new test file so I may not be able to provide examples for you guys to replicate on your end without providing real files which isn’t possible. What would potentially cause this and why it only happens when I update to the new version? Another occurrence that happened and is when adding a page from another visio file, the OLE object is crossed out box even if the table wasn’t even edited.
TestSamples.zip (390.1 KB)
Code Snippet used with TestSamples.zip:
Diagram diagram = new Diagram(filepath);
foreach (Page page in diagram.Pages)
{
Shape OLE_Shape = page.Shapes.GetShape("ole");
if (OLE_Shape.Type == TypeValue.Foreign)
{
if (OLE_Shape.ForeignData.ForeignType == ForeignType.Object)
{
Stream Ole_stream = new MemoryStream(OLE_Shape.ForeignData.ObjectData);
Aspose.Cells.FileFormatInfo info = Aspose.Cells.FileFormatUtil.DetectFileFormat(Ole_stream);
if (info.LoadFormat == LoadFormat.Xlsx || info.LoadFormat == LoadFormat.Xlsx)
{
Workbook Book = new Workbook(new MemoryStream(OLE_Shape.ForeignData.ObjectData));
Worksheet Sheet = Book.Worksheets[0];
Cell cellA = Sheet.Cells["A2"];
cellA.PutValue("bug");
Cell cellB = Sheet.Cells["B2"];
cellB.PutValue("bug");
Cell cellC = Sheet.Cells["C2"];
cellC.PutValue("bug");
Cell cellD = Sheet.Cells["D2"];
cellD.PutValue("bug");
Cell cellE = Sheet.Cells["E2"];
cellE.PutValue("bug");
MemoryStream outM = new MemoryStream();
Book.Save(outM, SaveFormat.Xlsx);
MemoryStream emfM = new MemoryStream();
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions
{
ImageType = Aspose.Cells.Drawing.ImageType.Emf,
OnePagePerSheet = true,
CheckWorkbookDefaultFont = true,
Transparent = true,
};
SheetRender sr = new SheetRender(Sheet, imgOpt);
sr.ToImage(0, emfM);
OLE_Shape.ForeignData.ImageData = emfM.ToArray();
OLE_Shape.ForeignData.ObjectData = outM.ToArray();
}
}
}
}
diagram.Save(savepath, SaveFileFormat.Vsdx);
@ger.vue
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): DIAGRAMNET-53157
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.
@ger.vue
Please add these sample codes before saving to emf
Workbook Book = new Workbook(new MemoryStream(OLE_Shape.ForeignData.ObjectData));
Worksheet Sheet = Book.Worksheets[0];
//Add these codes to set margin
Sheet.PageSetup.BottomMargin = 0;
Sheet.PageSetup.TopMargin = 0;
Sheet.PageSetup.LeftMargin = 0;
Sheet.PageSetup.RightMargin = 0;
Thanks.
1 Like
@philip.zhou
Thanks for the reply! Setting the margins did help with the image resize. I’ll just need to play around with the math to resize it appropriately when rows are deleted so it doesn’t stretch vertically.
I am still having issues upgrading the version to the latest 23.5.0 though. The margin setting will work with my current version, 22.1.0, but with 23.5.0 the table isn’t produced and only show a crossed out box. I’ve attached images of the different versions output of the table. Both runs on the same source code and working on the same diagrams, but with only the package version being different. What would be causing this issue when only updating to the latest version?
V22.1.0.PNG (12.7 KB)
V23.5.0.PNG (5.6 KB)
@ger.vue
Thanks for the screenshot.
We apologize for the inconvenience, but we were unable to reproduce the issue using the sample file from the provided zip file.
Here is my complete (runnable) sample code for your reference:
Diagram diagram = new Diagram(“TestOLEVisio.vsdx");
foreach (Page page in diagram.Pages)
{
Shape OLE_Shape = page.Shapes.GetShape("ole");
if (OLE_Shape.Type == TypeValue.Foreign)
{
if (OLE_Shape.ForeignData.ForeignType == ForeignType.Object)
{
Stream Ole_stream = new MemoryStream(OLE_Shape.ForeignData.ObjectData);
Aspose.Cells.FileFormatInfo info = Aspose.Cells.FileFormatUtil.DetectFileFormat(Ole_stream);
if (info.LoadFormat == LoadFormat.Xlsx || info.LoadFormat == LoadFormat.Xlsx)
{
Workbook Book = new Workbook(new MemoryStream(OLE_Shape.ForeignData.ObjectData));
Worksheet Sheet = Book.Worksheets[0];
Sheet.PageSetup.BottomMargin = 0;
Sheet.PageSetup.TopMargin = 0;
Sheet.PageSetup.LeftMargin = 0;
Sheet.PageSetup.RightMargin = 0;
Cell cellA = Sheet.Cells["A2"];
cellA.PutValue("bug");
Cell cellB = Sheet.Cells["B2"];
cellB.PutValue("bug");
Cell cellC = Sheet.Cells["C2"];
cellC.PutValue("bug");
Cell cellD = Sheet.Cells["D2"];
cellD.PutValue("bug");
Cell cellE = Sheet.Cells["E2"];
cellE.PutValue("bug");
MemoryStream outM = new MemoryStream();
Book.Save(outM, SaveFormat.Xlsx);
MemoryStream emfM = new MemoryStream();
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions
{
ImageType = Aspose.Cells.Drawing.ImageType.Emf,
OnePagePerSheet = true,
CheckWorkbookDefaultFont = true,
Transparent = true,
};
SheetRender sr = new SheetRender(Sheet, imgOpt);
sr.ToImage(0, emfM);
OLE_Shape.ForeignData.ImageData = emfM.ToArray();
OLE_Shape.ForeignData.ObjectData = outM.ToArray();
}
}
}
}
diagram.Save( "Out.vsdx", SaveFileFormat.Vsdx);
Please find attached the output file for your reference.Out.zip (200.4 KB)
Could you please create a standalone console application with latest version of Aspose.Diagram for .NET, zip the project and post us, we will check it soon.
Thanks.
@philip.zhou
I created a standalone console application and was able to reproduce the bug in it. Gave the test application to a tester and they were also able to replicate the issue so I’m hoping it will do they same for you when you run it.
Quick rundown, pretty much added everything as mentioned above and also a small logic to add pages from a different visio file to the main file.
You’ll need to reference the path of your license in the code.
Issues presented in Output:
- “THIRD” Page table isn’t produced.
- “FOURTH” thru “EIGHTH” pages are from the second visio file. Simply adding the page and it’s masters to the main diagram with zero edits. Somehow tables in “SIXTH”, “SEVENTH”, and “EIGHTH” got switched out to random tables in the main visio file.
TestConsoleApp.zip (9.7 MB)
@ger.vue
Thanks for providing us the sample project,
After an initial test, I reproduced the issue as you mentioned by using template file.
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): DIAGRAMNET-53166
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.
The issues you have found earlier (filed as DIAGRAMNET-53166) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou