This project has moved and is read-only. For the latest updates, please go here.

How to Open a .xlsx large size file

Apr 23, 2014 at 9:41 PM
Edited Apr 23, 2014 at 11: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=2.0.0.0, 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)))
                Next

                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
                    Next
                    tbl.Rows.Add(nrow)
                Next
                ds.Tables.Add(tbl)

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

Thank You!
Apr 24, 2014 at 1:14 PM
Edited Apr 29, 2014 at 1: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 Packing.io, so there isn´t issues with IsolatedStorage.


EPPlus 4 Beta https://epplus.codeplex.com/releases/view/118053