none
Type 'SpreadsheetDocument' is not defined ASP.Net and VB.Net RRS feed

  • Question

  • I am building an ASP.Net application, and have created a reference to the opendocumentxml.dll.

    I have then created the following code see below. The application compiles (builds) without any errors and opens up the browser where upon it tells me the "Type spreadsheetDocument is not defined". If I look in the detailed compiler messages I can also see workbook is undefined etc

    What am I missing? Do I need to have Office 2007 installed on my system to use the OpenXML 2.0 libraries, currently I am running office XP.


    Imports System.IO
    Imports System.Linq
    Imports DocumentFormat.OpenXml
    Imports DocumentFormat.OpenXml.Packaging
    Imports DocumentFormat.OpenXml.Spreadsheet
    Public Class clsExcel 

     

     

    Public Sub NewSpreadsheet()

    Dim sprdsheet As SpreadsheetDocument = SpreadsheetDocument.Create(FileName, SpreadsheetDocumentType.Workbook)
    Dim WrkBookPart As WorkbookPart = sprdsheet.AddWorkbookPart
    Dim wrkbook As New Workbook
    Dim WrkSheetPart As WorksheetPart = WrkBookPart.AddNewPart(Of WorksheetPart)
    Dim wrksheet As New Worksheet
    Dim SheetData As New SheetData

    ' More code here
    end sub
    end class

     

    Tuesday, November 24, 2009 1:55 PM

Answers

  • Hi, Markp11

    Thanks for your question.

    First of all, open xml sdk does not depend on the exsitence of Office 2007 or other edition of Office. I have compiled your code above and run the raw VB file on a machine without OFFICE App. It works.

    Secondly, I think the problem you encountered may be related to ASP .NET's mechanism to load the dll file. Perhaps you may find some solutions in that field.

    Thanks,
    Raymond  
    Wednesday, November 25, 2009 9:20 AM
  • I have tracked down the issue, it was because I was putting my code in a seperate App_Code folder, as soon as I moved the code to the App_Data folder everything started working. However up until this point all of my other code had and does work fine being located in an App_Code folder.

    I am not sure why this should cause a problem, however it now works.

    Thanks Raymond for pointing me in the right direction.
    Wednesday, November 25, 2009 9:39 AM

All replies

  • Hi, Markp11

    Thanks for your question.

    First of all, open xml sdk does not depend on the exsitence of Office 2007 or other edition of Office. I have compiled your code above and run the raw VB file on a machine without OFFICE App. It works.

    Secondly, I think the problem you encountered may be related to ASP .NET's mechanism to load the dll file. Perhaps you may find some solutions in that field.

    Thanks,
    Raymond  
    Wednesday, November 25, 2009 9:20 AM
  • I have tracked down the issue, it was because I was putting my code in a seperate App_Code folder, as soon as I moved the code to the App_Data folder everything started working. However up until this point all of my other code had and does work fine being located in an App_Code folder.

    I am not sure why this should cause a problem, however it now works.

    Thanks Raymond for pointing me in the right direction.
    Wednesday, November 25, 2009 9:39 AM