Dear Aspose team,
I need to place a word file content in to an excel file. kindly let me know how can i do that.
Thank you
Dear Aspose team,
I need to place a word file content in to an excel file. kindly let me know how can i do that.
Thank you
Hi,
Thank you for considering Aspose.
Well, if you want to add a word document to an excel file, you can embed word document as Ole Object in your excel file. Please see the following sample code in this regard,
Sample code:
//Define a string variable to store the image path.
string ImageUrl = @"f:\test\school.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 an word file path in a variable.
string path = @"f:\test\MyDoc.doc";
//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();
int intIndex = 0;
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.OleObjects.Add(14, 3, 200, 220, imageData);
workbook.Worksheets[0].OleObjects[intIndex].FileType = OleFileType.Doc;
workbook.Worksheets[0].OleObjects[intIndex].ObjectData = objectData;
workbook.Worksheets[0].OleObjects[intIndex].SourceFullName = path;
//Save the excel file
workbook.Save(@"f:\test\testolesobject.xls");
Also, please check the doc topic for your reference:
Thank You & Best Regards,
Dear Aspose Team,
I used your code, but i still get the following error.
CS0200: Property or indexer 'Aspose.Cells.OleObject.SourceFullName' cannot be assigned to -- it is read only
Am i using the older version of your dll? Kindly let me know
Thank you.
Hi,
Yes, I think you might be using some older version of the component. Kindly try our latest version 4.7.1: http://www.aspose.com/community/files/51/file-format-components/aspose.cells-for-.net-and-java/entry174461.aspx
Thank you.