Hi Guys,
I am gettings this compiler error:
Compiler Error Message: BC30456: 'Where' is not a member of 'System.Collections.Generic.IEnumerable(Of DocumentFormat.OpenXml.Spreadsheet.Sheet)'.
On other pages the MS excel works fine so I doubt the .dll is borken or something.if I replace the "where" with firstOrDefault or ElementAt(0) its the same error.
Try adding the below line
using System.Linq;
Thanks
Arun
Hi metalray,
Not sure why you are seeing the error you are seeing. I modified your code slightly so I could put into a module:
Imports System.Data.SqlClient Imports System.Net.Mail Imports DocumentFormat.OpenXml Imports DocumentFormat.OpenXml.Packaging Imports DocumentFormat.OpenXml.Spreadsheet Imports System.IO Module Module1 Sub Main() 'Open MS Excel template Dim sourceBytes() As Byte = File.ReadAllBytes("~\TemplateDocs\Gddddd.xlsx") Dim ms As New MemoryStream ms.Write(sourceBytes, 0, sourceBytes.Length) Using myWorkbook As SpreadsheetDocument = SpreadsheetDocument.Open(ms, True) Dim wbPart As WorkbookPart = myWorkbook.WorkbookPart Dim sheet = wbPart.Workbook.Descendants(Of Sheet)().Where(Function(s) s.Name = "test").FirstOrDefault Dim worksheetPart As WorksheetPart = DirectCast(myWorkbook.WorkbookPart.GetPartById(sheet.Id), WorksheetPart) End Using End Sub End Module
-Eric