Embed the files into excel

Hi,
I have some files(pdf,docx,jpg,pptx etc.) which i want to embed to excel cells and then download that excel, Any way i achieve that?

@Amrinder_Singh
Regarding the operation of OLE objects, please refer to the following documents:

Thanks it worked, one more doubt
image.png (25.6 KB)
One more doubt when i double click on file it keeps opening like this(above image) instead in the new word document
or it keeps like the below pic
image.png (53.4 KB)

@Amrinder_Singh
Please use OleObject.DisplayAsIcon property to control that the specified object is displayed as an icon and the image will not be auto changed.

The sample code as follows:

sheet.OleObjects[0].DisplayAsIcon = true;

Hope helps a bit.

Yes working now, Thank you so much

@Amrinder_Singh
You are welcome. If you have any questions, please feel free to contact us.

Hi,
Any way i can zip the files i have and attach the zip file to excel cell?

@Amrinder_Singh,

Yes, you may zip your desired files in the archive and embed it into Excel spreadsheets via Aspose.Cells for .NET APIs. See the following sample code for your reference.
e.g.
Sample code:

Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Define a string variable to store the image path.
string ImageUrl = "g:\\test\\report.jpg";
//Get the picture into the streams.
FileStream fs = File.OpenRead(ImageUrl);
//Define a byte array.
byte[] imageData = new Byte[fs.Length];
//Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length);
//Close the stream.
fs.Close();
//Get zip file path in a variable.
string path = "g:\\test2\\Report90043.zip";
//Get the file into the streams.
fs = File.OpenRead(path);
//Define an array of bytes.
byte[] objectData = new Byte[fs.Length];
//Store the file from streams.
fs.Read(objectData, 0, objectData.Length);
//Close the stream.
fs.Close();
sheet.OleObjects.Add(0, 0, 40, 40, imageData);
//Set embedded ole object data.
sheet.OleObjects[0].ObjectData = objectData;
sheet.OleObjects[0].FileFormatType = FileFormatType.Unknown;

sheet.OleObjects[0].HeightInch = 0.64;
sheet.OleObjects[0].WidthInch = 0.78;
sheet.OleObjects[0].DisplayAsIcon = true;
sheet.OleObjects[0].ObjectSourceFullName = path;

            
//Save the excel file
workbook.Save("g:\\test2\\out1.xlsx"); 

Hope, this helps a bit.

image.png (34.1 KB)

Getting this error while extracting the attached zip file

@Amrinder_Singh
By running the sample code provided by @amjad.sahi earlier, we can extract the files inside normally. Please refer to the attachment (71.8 KB).

Can you extract and view the zip file from the attachment(out.xlsx) normally? Also, can you directly extract files from zip(a.zip) locally through tools?