This project has moved. For the latest updates, please go here.

How to Open a .xlsx large size file

Apr 23, 2014 at 8:41 PM
Edited Apr 23, 2014 at 10:51 PM
When I am debugging I can open a file of 3 MB.
But now that I just published my project, the server throws this Exception with files of more than 1MB :

Request for the permission of type 'System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

Just Right after executing pck.Load(New IO.FileInfo(paramPathFile).OpenRead)

Here is the complete method:

Public Shared Function ImportFromMsExcel(ByVal paramPathFile As String, ByVal pStartRow As Integer, ByVal pStartColumn As Integer, ByVal pHasHeader As Boolean, Optional ByVal pStartSheet As Integer = 1) As DataSet
       If paramPathFile.Contains(".xlsx") Then
            Dim ds As New DataSet()
            Dim pck = New OfficeOpenXml.ExcelPackage()
            pck.Load(New IO.FileInfo(paramPathFile).OpenRead)
            If pck.Workbook.Worksheets.Count <> 0 Then
                Dim tbl As New DataTable
                Dim ws = pck.Workbook.Worksheets(pStartSheet)

                Dim hasHeader = pHasHeader

                For Each firstRowCell In ws.Cells(pStartRow, pStartColumn, pStartRow, ws.Dimension.End.Column)
                    tbl.Columns.Add(If(hasHeader, Replace(Replace(firstRowCell.Text.Trim(), Chr(10), ""), Chr(13), ""), String.Format("Column {0}", firstRowCell.Start.Column)))

                Dim startRow = If(hasHeader, pStartRow + 1, pStartRow)
                For rowNum = startRow To ws.Dimension.End.Row
                    Dim nrow As DataRow = tbl.NewRow()
                    For colNum As Integer = 0 To tbl.Columns.Count - 1
                        nrow(colNum) = ws.Cells(rowNum, colNum + pStartColumn).Text

            End If
            Return ds
            Throw New Exception("")
        End If
    End Function
Does anyone have an idea of what am I missing?

Thank You!
Apr 24, 2014 at 12:14 PM
Edited Apr 29, 2014 at 12:32 PM
Probably you are using EPPlus 3.1, this version is a little tricky to setup your server to work flawless. If you really want to use this version, there is a lot of threads about this.

I recommend you to try our new beta version, in this new version we are using Dotnetzip instead of, so there isn´t issues with IsolatedStorage.

EPPlus 4 Beta