Hi! Aspose Team,
I have the requirement to add the embedded excel in the PPT, I have tried adding it but the size of the embedded excel is quite large & I am facing issue in scrolling the embedded excel.
Is there a way to determine the size of embedded excel according the PPT slide height & width.
I have attached the sample code & excel for the reference.
Example.zip (9.0 KB)
public class OleFrameForGrid {
public static void main(String[] args) throws Exception {
String dataDir = “D://AsposeSlides//”;
boolean IsExists = new File(dataDir).exists();
if (!IsExists)
new File(dataDir).mkdirs();
// Instantiate Prsentation class that represents the PPTX
Presentation pres = new Presentation();
try
{
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
sld.getShapes().getParentGroup().getFillFormat().setFillType(FillType.NoFill);
// Load an cel file to stream
FileInputStream fs = new FileInputStream(dataDir + "Example.xlsx");
ByteArrayOutputStream mstream = new ByteArrayOutputStream();
byte[] buf = new byte[4096];
while (true)
{
int bytesRead = fs.read(buf, 0, buf.length);
if (bytesRead <= 0)
break;
mstream.write(buf, 0, bytesRead);
}
// Create data object for embedding
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(mstream.toByteArray(), "xlsx");
float width = (float)pres.getSlideSize().getSize().getWidth();
float height = (float)pres.getSlideSize().getSize().getHeight();
// Add an Ole Object Frame shape
IOleObjectFrame oleObjectFrame = sld.getShapes().addOleObjectFrame(0, 0, (float)pres.getSlideSize().getSize().getWidth(),
(float)pres.getSlideSize().getSize().getHeight(), dataInfo);
//Write the PPTX to disk
pres.save(dataDir + "OleEmbed_out_6.pptx", SaveFormat.Pptx);
System.out.println("Created EmbedObject in PPT");
}
finally
{
if (pres != null) pres.dispose();
}
//ExEnd:AddOLEObjectFrame
}
}