Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

Commented Unassigned: unable to read an excel file [12876]

$
0
0
dear sir

i have an asp.net application that use the excel.dll to read the excel spread-sheet it works fine. however, today i encounter a file that looks fine but when the code read it, it cause exception.

the asp.net code looks like the following:

Dim iFileNameLeng As Integer = 0
Dim sFileNamePath As String
'Dim sFileNameONly As String
If (Not FileUpload1 Is Nothing) AndAlso (FileUpload1.HasFile) Then
sFileNamePath = FileUpload1.PostedFile.FileName
iFileNameLeng = InStr(1, StrReverse(sFileNamePath), "\")
'If iFileNameLeng > 0 Then
'FileUpload1.PostedFile.SaveAs("C:\yyyy.txt")
Dim bytes As Byte() = FileUpload1.FileBytes
Dim stream As MemoryStream = New MemoryStream(bytes)
Dim excelReader As IExcelDataReader
'If (sFileNamePath.IndexOf(".xlsx") > -1) OrElse (sFileNamePath.IndexOf(".xlsm") > -1) Then
If (sFileNamePath.IndexOf(".xlsx") > -1) Then
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream)
Else
excelReader = ExcelReaderFactory.CreateBinaryReader(stream)
End If
excelReader.IsFirstRowAsColumnNames = True
Dim ds As DataSet = excelReader.AsDataSet

While (excelReader.Read)
End While
excelReader.Close()

The exception happened in the ExcelReaderFactory.CreateBinaryReader,

The exception message text:

NotSupportedException was unhandled by user code
No data is available for encoding 24128
Comments: ** Comment from web user: bvolkan **

The file is protected. I have the same problem. There is no Unprotect method in this library.


Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>