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

Problem with large files

Jun 11, 2010 at 3:33 PM

Hello,

We are using your library in our asp.net project whereby the administrator exports the list of customers to excel. It is working successfully for 62,344 rows in excel file (approx. 5 mb) on the development server. Unfortunately, the export does not work on production server only when the file exceeds 4 mb. !?

Any help would be highly appreciated.

Best Regards,

 

Coordinator
Jun 13, 2010 at 7:31 PM

Do you upload a file to the server? If so I think the default max size in IIS is 4MB. You can change it somewhere in the machine.config file, I think.

Jan 

Jun 14, 2010 at 6:58 AM

Hello Jan,

No File System included. I just return the array of byte[] > 4 MB generated on the server and having the following exception:

Message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)), Trace:    at System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
   at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCurrentStore()
   at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder..ctor()
   at MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile()
   at MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName)
   at MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream()
   at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary()
   at MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MS.Internal.IO.Packaging.CompressEmulationStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MS.Internal.IO.Packaging.CompressStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(String value)
   at System.IO.TextWriter.Write(String format, Object arg0, Object arg1)
   at OfficeOpenXml.ExcelWorksheet.UpdateRowCellData(StreamWriter sw)
   at OfficeOpenXml.ExcelWorksheet.SaveXml()
   at OfficeOpenXml.ExcelWorksheet.Save()
   at OfficeOpenXml.ExcelWorkbook.Save()
   at OfficeOpenXml.ExcelPackage.GetAsByteArray(Boolean save)
   at OfficeOpenXml.ExcelPackage.GetAsByteArray()  

I will search how to change the 4 MB default Max as you suggested and let you know.

Thank you for your help.

Coordinator
Jun 14, 2010 at 7:12 AM

Seems to be a permission problem with isolated storage. Found this when i had a quick search.

 

Jun 15, 2010 at 6:12 AM

Great article,

After creating the IsolatedStorage folder at the right location and setting the designated permission. Everything worked as expected.

Thank you for your kind cooperation.

Aug 18, 2011 at 8:18 PM

I also had the same issue. I followed that article but now I get the error below. Any ideas what it could be?

Thank You

 

System.IO.IsolatedStorage.IsolatedStorageException: Initialization failed.

[IsolatedStorageException: Initialization failed.]
   System.IO.IsolatedStorage.IsolatedStorageFile.CreateRandomDirectory(String rootDir) +131
   System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope) +244
   System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope) +137
   System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope) +213
   System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope) +56
   System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType) +59
   MS.Internal.IO.Packaging.ReliableIsolatedStorageFileFolder.GetCurrentStore() +34
   MS.Internal.IO.Packaging.ReliableIsolatedStorageFileFolder..ctor() +64
   MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile() +54
   MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName) +114
   MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream() +23
   MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary() +310
   MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) +184
   MS.Internal.IO.Packaging.DeflateEmulationTransform.Decompress(Stream source, Stream sink) +198
   MS.Internal.IO.Packaging.CompressEmulationStream..ctor(Stream baseStream, Stream tempStream, Int64 position, IDeflateTransform transformer) +163
   MS.Internal.IO.Packaging.CompressStream.ChangeMode(Mode newMode) +246
   MS.Internal.IO.Packaging.CompressStream.Seek(Int64 offset, SeekOrigin origin) +313
   MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Seek(Int64 offset, SeekOrigin origin) +34
   MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Read(Byte[] buffer, Int32 offset, Int32 count) +159
   System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer) +82
   System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count) +119
   System.IO.TextReader.ReadBlock(Char[] buffer, Int32 index, Int32 count) +32
   OfficeOpenXml.ExcelWorksheet.GetWorkSheetXml(Stream stream, Int64 start, Int64 end) +153
   OfficeOpenXml.ExcelWorksheet.CreateXml() +219
   OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, eWorkSheetHidden hide) +620
   OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage xlPackage) +752
   OfficeOpenXml.ExcelWorkbook.get_Worksheets() +32
   test.myTest() in E:\inetpub\ea\PayrollDeductions\test.aspx.cs:76
   test.onClick(Object sender, EventArgs e) in E:\inetpub\ea\PayrollDeductions\test.aspx.cs:49
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Coordinator
Aug 23, 2011 at 7:59 PM

Not sure, I haven't had this problem, but Isolated storage have a build in limit of 1Mb, so make sure the user running the context have permission to write to the isolateds storage folder.

Oct 20, 2011 at 5:12 PM

I am reading an excel file, of over 5MB, using a stream.

 

using (var package = new ExcelPackage(this._Stream))

I am encountering this error.

Any suggestions would be appreciated.

Message "Unable to determine the identity of domain."

StackTrace    at System.IO.IsolatedStorage.IsolatedStorage._GetAccountingInfo(Evidence evidence, Type evidenceType, IsolatedStorageScope fAssmDomApp, Object& oNormalized)  at System.IO.IsolatedStorage.IsolatedStorage.GetAccountingInfo(Evidence evidence, Type evidenceType, IsolatedStorageScope fAssmDomApp, String& typeName, String& instanceName)  at System.IO.IsolatedStorage.IsolatedStorage._InitStore(IsolatedStorageScope scope, Evidence domainEv, Type domainEvidenceType, Evidence assemEv, Type assemblyEvidenceType, Evidence appEv, Type appEvidenceType)  at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)  at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)  at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder..ctor()  at MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile()  at MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName)  at MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream()  at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary()  at MS.Internal.IO.Packaging.DeflateEmulationTransform.Decompress(Stream source, Stream sink)  at MS.Internal.IO.Packaging.CompressEmulationStream..ctor(Stream baseStream, Stream tempStream, Int64 position, IDeflateTransform transformer)  at MS.Internal.IO.Packaging.CompressStream.ChangeMode(Mode newMode)  at MS.Internal.IO.Packaging.CompressStream.Seek(Int64 offset, SeekOrigin origin)  at MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Seek(Int64 offset, SeekOrigin origin)  at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Read(Byte[] buffer, Int32 offset, Int32 count)  at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)  at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)  at System.IO.TextReader.ReadBlock(Char[] buffer, Int32 index, Int32 count)  at OfficeOpenXml.ExcelWorksheet.GetWorkSheetXml(Stream stream, Int64 start, Int64 end)  at OfficeOpenXml.ExcelWorksheet.CreateXml()  at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, eWorkSheetHidden hide)  at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage xlPackage)  at OfficeOpenXml.ExcelWorkbook.get_Worksheets()  at OfficeOpenXml.ExcelWorkbook.GetDefinedNames()  at OfficeOpenXml.ExcelPackage.get_Workbook()  at Sylvania.LRG.Adapter.ExcelAdapter.ImportFromExcelFile()  at SharePoint.SiteMapGeneratorFeature.LoadLRGData.ImportData()

Coordinator
Oct 28, 2011 at 3:07 PM

No, I haven't had this problem, but my guess is that this is a permission problem when isolated storage tries to write to disc.

Jan 12, 2012 at 9:26 PM

My file sizes were 2 times larger before implementing this workaround. Basically, I now check to see if what is being written to the cell has a valid value or is an empty string. If it is empty, I simply skip writing to that cell. Since many of the cells are empty, it reduces file size by 50%.

 

if (String.IsNullOrEmpty(Convert.ToString(row[j]))                            || Convert.ToString(row[j]) == ""                            )                        {                        }                        else                        {

 

 

I spent a lot of time figuring this out, hopefully, you won't have too :)

Oct 24, 2012 at 9:18 PM

After 10MB, System.IO.Packaging automatically switches to Isolated File Storage, which is not actually available in some situations (particularly running on a server). This behavior cannot be changed within EPPlus, it's part of the MS BCL.

Related issue and more information:

http://epplus.codeplex.com/workitem/14762