Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Wed Jun 24, 2015 3:29 am

Hi,

I am evaluating the Spire Presentation for .NET, and I need to know how to insert an Excel file into a slide. I want the object to be shown as an icon, you open the Excel file when clicked with the mouse, as shown below:

Image

How to do this in VB.NET?

Thanks in advance,

Marcelo Camarate

camarate
 
Posts: 3
Joined: Sun Jan 25, 2015 3:33 pm

Wed Jun 24, 2015 9:53 am

Hello,

Thanks for your inquiry.
We will look into it and let you know ASAP.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Jun 25, 2015 3:46 am

Hello,

Thanks for your inquiry.
Here is the code for your reference.
Code: Select all
   Presentation ppt = new Presentation();
            Image img = Image.FromFile("d:\\1.png");
            Spire.Presentation.Drawing.IImageData oleImage = ppt.Images.Append(img);
            Rectangle rec = new Rectangle(60, 60, img.Width, img.Height);
            byte[] fromArray = File.ReadAllBytes("d:\\sample.xlsx");
            Spire.Presentation.IOleObject oleObject = ppt.Slides[0].Shapes.AppendOleObject("excel", fromArray, rec);
            oleObject.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage;
            oleObject.ProgId = "Excel.Sheet.12";
            oleObject.IsIconVisible = true;
            ppt.SaveToFile("5255.pptx", Spire.Presentation.FileFormat.Pptx2010);


Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Jun 26, 2015 8:30 am

Hello,

Have you tried the code?
Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Sep 10, 2018 2:35 pm

Hello Sweety,

I have used your given code and it ran successfully. Thanks you so much.
Now I am able to insert Excel object using your code.

But the only thing what i want is, to give the caption of that object.
please see screen shot.

Spire Help.png

bkthebest
 
Posts: 7
Joined: Fri Apr 24, 2015 9:00 am

Tue Sep 11, 2018 8:16 am

Dear brijendra,

Thanks for your inquiry.
Sorry that our Spire.Presentation can't achieve your requirement to set the caption of the object. After setting the caption of icon in MS PowerPoint, it actually generates a picture which contains icon and caption. Hence, I suggest that you use MS PowerPoint to set the caption icon, then save the picture and use our product to embed the picture to object.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Tue Sep 11, 2018 1:18 pm

Hello Nina,

I did, what you suggested and achieved my requirement. thanks a lot.

My new requirement is like, I need to insert an image in a rectangle. The Rectangle is already in the PPT slide.
I don't want to add new shape in PPT but giving coordinates.

I have googled but I got only solution like to add custom shape in PPT slide.

Please suggest.

Thanks in advance

Regards
Brijendra

bkthebest
 
Posts: 7
Joined: Fri Apr 24, 2015 9:00 am

Wed Sep 12, 2018 4:20 am

Hi Brijendra,

Thanks for your feedback.
As for your new requirement, you could first obtain the rectangle, and then insert an image in it. Sample code is as follows. If there is any question, please offer your sample PPT so that we can provide the solution accordingly.
Code: Select all
//Load PPT file
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
//Traverse shapes in PPT file
foreach(IShape s in ppt.Slides[0].Shapes)
{
    IAutoShape shape = (IAutoShape)s;
    if (shape.ShapeType == ShapeType.Rectangle)
    {
        string picUrl = "C:\\pic.png";
        shape.Fill.FillType = FillFormatType.Picture;
        shape.Fill.PictureFill.Picture.Url = picUrl;
        shape.Fill.PictureFill.FillType = PictureFillType.Stretch;
        shape.ShapeStyle.LineColor.Color = Color.Transparent;
    }
}
ppt.SaveToFile("InsertImage.pptx", FileFormat.Pptx2013);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Mon Sep 17, 2018 8:52 am

Dear Brijendra,

Hope you're doing well.
Did my code help you? Could you give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Tue Sep 18, 2018 11:25 am

Hi Nina,

Thanks a lot. your code doing good and fulfill my requirement.

If you don't mind, could you please provide me another code snippet
My requirement is :

I need to insert HTML into the PPT from a Textarea which is on a web page.
HTML may contains bold, Italic, BulletlList, color etc, any type of formatting.
Please see screen shot

I don't want to use inbuilt function/properties like
textParagraph.BulletType = TextBulletType.Numbered; and
textParagraph.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;
as there is lots of dynamic code on web page
i can't play too much with IF/ELSE condition

I have tried with the code on below link but it is just inserting paragraph
Append HTML String to PowerPoint in C#, VB.NET(which is on e-iceblue site)

waiting for your reply

Thanks in Advance
Regards
Brijendra

bkthebest
 
Posts: 7
Joined: Fri Apr 24, 2015 9:00 am

Wed Sep 19, 2018 6:38 am

Hello,

Thanks for your feedback.
Our Spire.Presentation supports inserting HTML which contains bold, Italic, color and other elements into powerpoint file. But as for the list-style-type (BulletlList), only the default type (disc) can be supported at present. To help us better investigate your case, could you please provide the html string you want to insert? Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Wed Sep 19, 2018 11:05 am

Hi Nina,

Thanks for your reply and taking interest in my queries.

No issue, I can be fine with default type (disc).
Please provide code for all styling that Spire.Presentation have like bold/italic/underline/default type (disc)/color etc

here is one example of string

<div class="toolbar">
<ul>
<li>TextArea</li>
<li><b>Image</b></li>
<li>Object</li>
</ul>
</div>

bkthebest
 
Posts: 7
Joined: Fri Apr 24, 2015 9:00 am

Thu Sep 20, 2018 6:24 am

Dear Brijendra,

Thanks for your feedback.
As per my understanding, you want to insert HTML string into PPT, and then set style of paragraphs. Please refer to below sample code. If this is not what you want, please provide your desired effect and more details for our reference.
Code: Select all
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 200, 100));
shape.TextFrame.Paragraphs.Clear();

//Insert HTML string
string htmlText = "<html><body><div class='toolbar'><ul><li>TextArea</li><li><b>Image</b></li><li>Object</li></ul></div></body></html>";
shape.TextFrame.Paragraphs.AddFromHtml(htmlText);

//Get the first paragraph
TextParagraph p1=shape.TextFrame.Paragraphs[0];
foreach (TextRange tr in p1.TextRanges)
{
    //Italic and Bold
    tr.IsItalic = TriState.True;
    tr.IsBold = TriState.True;
}
//Get the second paragraph
TextParagraph p2=shape.TextFrame.Paragraphs[1];
foreach (TextRange tr in p2.TextRanges)
{
    //Color
    tr.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    tr.Format.Fill.SolidColor.Color = Color.Red;
}
//Get the third paragraph
TextParagraph p3 = shape.TextFrame.Paragraphs[2];
//Bullet style
p3.BulletType = TextBulletType.Numbered;
p3.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;
foreach (TextRange tr in p3.TextRanges)
{
    //Underline
    tr.TextUnderlineType = TextUnderlineType.Single;
}
//Save the file
ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Wed Sep 26, 2018 7:37 am

Hello,

Greetings from E-iceblue.
Did my code help you?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Thu Oct 11, 2018 6:05 pm

Hi Nina,

Yes, your code is very helpful for me, thanks a lot.

bkthebest
 
Posts: 7
Joined: Fri Apr 24, 2015 9:00 am

Return to Spire.Presentation