This project is read-only.

WriteDelegate Execution Order

Sep 17, 2010 at 4:44 PM

I’m designing a web app that streams .xlsx (zip) files to users and am impressed with DotNetZip’s ability to handle zip streaming in quick and elegant code!

I’ve got a shell template file stored in memory and have XML-writing .AddEntry() WriteDelegates hooked up to stream the worksheet .xml files and the sharedstrings .xml file. The sharedstrings .xml must be the last file to be streamed as its contents are not fully known until the other worksheet .xml files have been processed. I have my worksheet .AddEntry() lines listed before the sharedstrings .AddEntry() line, however the sharedstrings WriteDelegate is still getting called first.

My guess is that the WriteDelegates get called in the order that the files appear in the Entries or EntriesSorted collection? Is there an easy way to enforce that my sharedstrigns .AddEntry() WriteDelegate gets streamed last?

Thanks in advance,

Tyler Andrews

Sep 19, 2010 at 6:26 PM

Ahh, yes I think the entries don't get written in the order they are added, but rather in the order they will appear in the zip. In DotNetZip, implicitly the order is alphabetic.  Seems like a limitation of the library.

To work around it, you could try saving twice.  Add all the entries except for sharedstrings.xml.  Then call Save().  Then add an additional entry, sharedstrings.xml.  Then call Save() again.