Free Support Forum - aspose.com

Mail merging images within Aspose.Cells

Received : 2007/10/14 22:45:51
Message : We are currently using Aspose.Words to mail merge images into a document, and would like to be able to do a similar thing with Aspose.Cells.

To perform a mail merge within Aspose.Cells, we are using the following code...

Dim MyWorkbookDesigner As WorkbookDesigner = New WorkbookDesigner()
MyWorkbookDesigner.Open(MyWorkbookTemplate)
MyWorkbookDesigner.SetDataSource(MyDataTable)
MyWorkbookDesigner.Process(True)

...and, this is working fine.

However, the code that we are using to handle the merging of images within within Aspose.Words is...

AddHandler MyDocument.MailMerge.MergeImageField, AddressOf MergeImageFieldHandler

Protected Overridable Sub MergeImageFieldHandler(ByVal Sender As Object, ByVal e As Aspose.Words.Reporting.MergeImageFieldEventArgs)
If e.FieldName = "ImageField" Then
If Not e.FieldValue Is DBNull.Value Then
e.ImageFileName = HttpContext.Current.Server.MapPath("~/Images/Image.png")
Else
e.ImageFileName = HttpContext.Current.Server.MapPath("~/Images/Spacer.gif")
End If
End If
End Sub

...and to the best of my knowledge there is no equivalent within Aspose.Cells, or at least no simple equivalent. I can find no similar events to handle.

Is there an equivalent that we can make use of?


This message was posted using Aspose.Live 2 Forum

Hi,

Thanks for considering Aspose.

Well, Currently Aspose.Cells does not support events. Do you know how to implement mail merge images in MS Excel. I am not sure if there is any direct way to implement this feature, if you know anything, could you give us some insight, so that may be able to try to get under way and implement it. I think you have to manually embed images repeatedly into Excel spreadsheet manually using your own code.

Thank you.

Is there any reason Aspose.Cells does not support events? Given a single event, this would be easy to implement.

We are currently performing a mail merge using Aspose.Cells and smart tagging. We basically use a WorbookDesigner, set a datasource and process.

To implement a mail merge with images we would need a single event, triggered each time a piece of data is merged into a cell. If the event coule pass back a cell reference and the data being merged, then it would be a simple matter for us to add an event handler that could take the data, (which is a url in our current datasource), and use it to load the image manually and insert it into the cell.

For performance issue we don't support events.

Actually in your case you can easily insert images in data cells. You can use Cells.FindString method the find cells that defined with smart markers then you can use Pictures.Add method to add images in your expected cells.