embedding a attachment using vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niklesh
    New Member
    • Apr 2009
    • 3

    embedding a attachment using vb.net

    Hi,

    I'm providing a link button in my page(which contains a datagrid) so that when the user clicks on it they will be able to see the contents of the datagrid in a separate excel file.I provide the user with the option of attaching documents while they use my application.I would want that particular attachment to be embedded into excel document along with other contents.Is there a way to do this?

    Note:I don't want to specify the link(location) where the attachment is present.Instead I would need the attached document itself to be embedded into the excel file.
    Last edited by debasisdas; Apr 15 '09, 07:18 AM. Reason: moved to vb.net forum.
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    Originally posted by niklesh
    Hi,

    I'm providing a link button in my page(which contains a datagrid) so that when the user clicks on it they will be able to see the contents of the datagrid in a separate excel file.I provide the user with the option of attaching documents while they use my application.I would want that particular attachment to be embedded into excel document along with other contents.Is there a way to do this?

    Note:I don't want to specify the link(location) where the attachment is present.Instead I would need the attached document itself to be embedded into the excel file.
    I really don't get what you are trying to accomplish

    So you have a datagrid exporting to excel.. what documents are going to be attached? where will they go? You say embedded into the excel document so I assume its a table/grid type layout attachment?

    Comment

    • niklesh
      New Member
      • Apr 2009
      • 3

      #3
      I have a excel file created,whose contents are generated by exporting contents from a datagrid, when the user clicks on a link provided.I want to append a document present in my server into the excel file created.

      Comment

      • aryanbs
        New Member
        • Mar 2009
        • 42

        #4
        Sample code below, please add reference to Microsoft.Offic e.Interop.Excel

        Imports Microsoft.Offic e.Interop


        Code:
          Dim MyExcel As New Excel.Application
                Dim wb As Excel.Workbook
                wb = MyExcel.Workbooks.Open("c:\backup\text.xls")
                Dim oleobjs = CType(wb.ActiveSheet.OleObjects, Excel.OLEObjects)
                oleobjs.Add(Link:=False, Filename:="c:\backup\test.doc")
        
                wb.Close(True)
                MyExcel.Quit()
                Try
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(source)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wb)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(MyExcel)
                    GC.Collect()
                    GC.WaitForPendingFinalizers()
        
                Catch ex As Exception
                    MyExcel = Nothing
                    wb = Nothing
                End Try

        Comment

        Working...