如何在excel单元格中保存blob文件

时间:2013-01-18 17:12:42

标签: mysql sql vb.net oracle

我的表包含存储账单的列(“file as pdf”)。

我的问题是我想将该表导出到excel表。

有可能吗?

到目前为止,我试过这个..

 Dim xapp As New Microsoft.Office.Interop.Excel.Application
    Dim wb As Workbook = xapp.Workbooks.Add
    Dim ws As Worksheet = wb.Worksheets(1)
    ws.Activate()

    'Fill header of the sheet----------------------------------

    For i As Integer = 1 To dgvcustomer.Columns.Count
        ws.Cells(1, i) = dgvcustomer.Columns(i - 1).HeaderText
    Next

    'End header------------------------------------------------

    Dim Dgrow, Dgcell, Dgcol As Integer
    Dgrow = 1
    Dgcell = 1

    'Fill Sheet -----------------------------------------------------------------------

    While (Dgrow <= dgvcustomer.Rows.Count)
        Dgcol = 1
        While (Dgcol <= ws.UsedRange.Columns().Count)
            ws.Cells(Dgrow + 1, Dgcol).value = dgvcustomer.Rows(Dgrow - 1).Cells(ws.Cells(1, Dgcol).value).Value
            Dgcol += 1
        End While
        Dgrow += 1
    End While

    'End fill sheet--------------------------------------------------------------------

    wb.SaveAs(dlgSaveFile.FileName)
    wb.Close()
    xapp.Quit()

此代码适用于非blob数据类型列,但对于blob,它会引发异常。

Exception image

1 个答案:

答案 0 :(得分:4)

没有。 Excel不支持在工作表的单元格中存储数据blob。

您应该将这些PDF分别导出到单个文件中,并在导出的工作表中指定文件名。

相关问题