How to insert a OLEObejct into a Excel file

Received : 2007/07/26 21:50:47
Message : When I try to insert a rtf filestream into a Excel file,I get the error message "This is not a structured storage file"
can you help me?


This message was posted using Aspose.Live 2 Forum

Hi,

Which version do you use?

Please try the attached verison.And see following codes:

Workbook workbook = new Workbook();
OleObjects oles = workbook.Worksheets[0].OleObjects;
FileStream fs = new FileStream(@"F:\FileTemp\test.emf", FileMode.Open);
byte[] imageData = new byte[fs.Length];
fs.Read(imageData, 0, imageData.Length);
int index = oles.Add(0, 0, 100, 100, imageData);
OleObject ole = oles[index];
ole.SetNativeSourceFullName(@"F:\FileTemp\Doc1.rtf");
fs = new FileStream(@"F:\FileTemp\Doc1.rtf", FileMode.Open);
imageData = new byte[fs.Length];
fs.Read(imageData, 0, imageData.Length);
ole.ObjectData = imageData;

workbook.Save(@"F:\FileTemp\dest.xls");

thanks for your anwser.

yes,I used the the attached verison,and successed to insert the rtf file into the excel.

but,I have another question that how to insert the rtf file,and display it in cell directly without clicking the image icon.


Hi,

Well, it is not available in that way. I think you have to click on the icon to get the rtf file.

Thank you.