locked
Exporting to Excel using OpenOfficeXML 2.0 - Type 'SpreadsheetDocument' is not defined RRS feed

  • Question

  • User1760474211 posted

    I have a requirement to be able to export data to an Excel spreadsheet (created on the fly) from an ASP.net application. I am attempting to use OpenOfficeXML 2.0 as this appears to be the  way to go?

    I have downloaded and installed the components from Microsofts site and set a reference in my Web Project to the DocumentFormat.OpenXML.dll, and as such in my classes I can see and reference all the objects associated with the DLL.

    My application builds ok with no reported errors, however on running the application the browser opens and then shows the following:

    Compiler Error Message: BC30002: Type 'SpreadsheetDocument' is not defined.

    Line 34:     Public Sub NewSpreadsheet()
    Line 35:
    Line 36:         Dim sprdsheet As SpreadsheetDocument = SpreadsheetDocument.Create(FileName, SpreadsheetDocumentType.Workbook)
    Line 37:         Dim WrkBookPart As WorkbookPart = sprdsheet.AddWorkbookPart
    Line 38:         Dim wrkbook As New Workbook

    At the start of my class I import the following:

    Imports System.IO

    Imports System.Linq
    Imports DocumentFormat.OpenXml
    Imports DocumentFormat.OpenXml.Packaging
    Imports DocumentFormat.OpenXml.Spreadsheet

    Public Class clsExcel

    Public Sub NewSpreadsheet()
    (see above)

     

    I am not sure what I am doing wrong / missing and the usual searching of the web is turning up nothing. Could someone please help?

    NB. I do not currently have Office 2007 installed on my PC so I am not sure if this is a pre-requisite for running OpenOfficeXML, my assumption is that it is not ?

     

     

     

    Tuesday, November 24, 2009 10:28 AM

All replies

  • User1760474211 posted

    Problem solved, the issue was purely down to having created an App_Code folder inside of the project, into which all of my code was placed, and up until I started trying to use the Open XML everything was working fine. To solve the problem I moved all of my code to the AppData folder and everything now works.

     

     

    Wednesday, November 25, 2009 7:19 AM