VB.NET Can't Find SpreadSheetDocument.Creat

Hello,

I am using Visual Studio 2017, programming in VB.NET.
I have a reference in my project to DocumentFormat.OpenXml (SDK2.5, Version 2.5.5631.0, Runtime Version 4.0.30319)

At the start of the module, I have the following:
Imports DocumentFormat.OpenXml
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Spreadsheet

My code (plagiarized from Google) is as follows:
 Public Function CreateWorkbook(fileName As String) As SpreadsheetDocument
    Dim spreadSheet As SpreadsheetDocument = Nothing
    Dim sharedStringTablePart As SharedStringTablePart
    Dim workbookStylesPart As WorkbookStylesPart

    Try
      ' Create the Excel workbook
      spreadSheet = New SpreadsheetDocument.Create(fileName, SpreadsheetDocumentType.Workbook, False)

      ' Create the parts and the corresponding objects
      ' Workbook
      spreadSheet.AddWorkbookPart()
      spreadSheet.WorkbookPart.Workbook = New Workbook()
      spreadSheet.WorkbookPart.Workbook.Save()

      ' Shared string table
      sharedStringTablePart = spreadSheet.WorkbookPart.AddNewPart(Of SharedStringTablePart)()
      sharedStringTablePart.SharedStringTable = New SharedStringTable()
      sharedStringTablePart.SharedStringTable.Save()

      ' Sheets collection
      spreadSheet.WorkbookPart.Workbook.Sheets = New DocumentFormat.OpenXml.Spreadsheet.Sheets()
      spreadSheet.WorkbookPart.Workbook.Save()

      ' Stylesheet
      workbookStylesPart = spreadSheet.WorkbookPart.AddNewPart(Of WorkbookStylesPart)()
      workbookStylesPart.Stylesheet = New Stylesheet()
      workbookStylesPart.Stylesheet.Save()
    Catch exception As System.Exception
      'System.Windows.MessageBox.Show(exception.Message, "Excel OpenXML basics", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand)
    End Try

    Return spreadSheet
  End Function

My problem is with spreadSheet = New SpreadsheetDocument.Create(fileName, SpreadsheetDocumentType.Workbook, False). I have an error that "Type 'SpreadSheetDocument.Create' is not defined." How do I fix this error?

I am an old VBA programmer struggling in VB.NET,  thanks ahead of time, as any help would be much appreciated!
Michael ClymerConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical Specialist/DeveloperCommented:
Try
spreadSheet = SpreadsheetDocument.Create(fileName, SpreadsheetDocumentType.Workbook, False)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael ClymerConsultantAuthor Commented:
Thanks that helped. It led me to see that I needed to add WindowsBase to my references.
0
Michael ClymerConsultantAuthor Commented:
Shaun was very speedy with a reply, and I do know that he would have helped me further, but with his suggestion, I discovered what the issue was. I needed to add WindowsBase to my references.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.