Using this code:
private void CopyWorkbookRangeToPresentation(Range sourceRange, Presentation targetPresentation)
{
// Copy the specified range to an intermediate workbook.
Workbook intermediateWorkbook = IsolateSourceRangeInAsposeWorkbook(sourceRange);
// Create a presentation from the intermediate workbook.
Presentation sourcePresentation = CreatePresentationFromAsposeWorkbook(intermediateWorkbook);
foreach (IShape shape1 in targetPresentation.Slides[0].Shapes)
if (shape1 is Table table)
Debug.WriteLine($"sourcePresentation -> Height: {table.Height}; Width: {table.Width}");
// Add the first shape in the source presentation to the target presentation.
IShape shape = targetPresentation.Slides[0].Shapes.AddClone(sourcePresentation.Slides[0].Shapes[0]);
foreach (IShape shape1 in targetPresentation.Slides[0].Shapes)
if (shape1 is Table table)
Debug.WriteLine($"After create -> Height: {table.Height}; Width: {table.Width}");
MemoryStream memoryStream = new MemoryStream();
targetPresentation.Save(memoryStream, Aspose.Slides.Export.SaveFormat.Pptx);
Presentation fixedPresentation = new Presentation(memoryStream);
foreach (IShape shape1 in fixedPresentation.Slides[0].Shapes)
if (shape1 is Table table)
Debug.WriteLine($"After fixed -> Height: {table.Height}; Width: {table.Width}");
shape.X = 72;
shape.Y = 72;
}
You can see that after cloning the table from the source presentation to the target presentation the size of the new table is reported incorrectly. Saving the target presentation to a memorty stream and then reloading it as a new presentation the size of the table is reported correctly.
OUTPUT FROM DEBUG STATEMENTS:
BEFORE CLONING:
sourcePresentation → Height: 182.76488; Width: 461.64938
sourcePresentation → Height: 182.76488; Width: 461.64938
sourcePresentation → Height: 182.76488; Width: 461.64938
AFTER CLONING:
After create → Height: 182.76488; Width: 461.64938
After create → Height: 182.76488; Width: 461.64938
After create → Height: 182.76488; Width: 461.64938
After create → Height: 612.75; Width: 792.75 (THIS IS THE NEW TABLE CLONE)
AFTER SAVING TO A STREAM AND REOPENING:
After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938 (THIS IS THE NEW TABLE CLONE)