SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

problem unzipping Office (2007) Open XML File Formats

Last post 11-05-2009 10:50 AM by Rajesh M. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-17-2009 4:45 PM

    problem unzipping Office (2007) Open XML File Formats

     I've been able to open a MS Word  .docx file with SharpZipLib, and read the various sections into a byte array by using the ZipInputStream.Read method on an instance of a ZipInputStream.

    After I have read the data into memory, I can inspect the uncompressed size of each XML document or Image. I can compare this to the size of each section that I can see in the original Word .docx file (add .zip to the end of a .docx docuemnt, and open it with windows Explorer to see the internal format of an Open XML File).

    The problem is, some of the sections read in just fine, but other sections are a bit larger after uncompressing than the ZIP file says it should be. Anywhere from one byte larger, to a few kilo-bytes larger.

    When I write the memory version back to disk in a new .docx format, both Word and Windows explorer say the ZIP file is corrupt, as does SharpZipLib when I try to re-read the file I just wrote.

    Has anybody run into similar problems when reading a Word .docx file in Open XML File Format, and writing it back out? The problem is certainly in the decompression, as the size of each section in memory is the same as the size of each section when I write it to disk, but the size of teh section in the original document is smaller.

    Thanks in advance for any help!

  • 11-02-2009 12:21 PM In reply to

    Re: problem unzipping Office (2007) Open XML File Formats

     HI

    I am trying to unzip the PPTX(2007) file using  ICSharpCode.SharpZipLib.Zip.The unzip files i am trying to place in Memory stream.

    From the steam ,i am trying to upgrade the concerned Xml files with my data.

    At the end of update,I am trying to update those files in stream and Zip the file.

    Finally when i am trying to open the PPTX throwing error message ,as files are corrupted.

    Please find the below sample code and help me

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • 11-03-2009 12:41 AM In reply to

    Re: problem unzipping Office (2007) Open XML File Formats

    Rajesh,

    What is "the PPTX(2007) file"?

    What is "TemplateResources.OpenXmlPPT" ?

    Please re-post code that is formatted readably, and can compile and run. Thanks, David

  • 11-03-2009 10:17 AM In reply to

    Re: problem unzipping Office (2007) Open XML File Formats

     What is "the PPTX(2007) file"?  power point File 2007

    What is "TemplateResources.OpenXmlPPT" ? It is a dummy template(PPTX file) stroed in resx file,which will be used as input for unzip

    The Problem i was facing is unable to open the PPTX file after updating all the concerned files. help me.

  • 11-05-2009 10:50 AM In reply to

    Re: problem unzipping Office (2007) Open XML File Formats

    Currently I am trying to unzip the pptx file with the help of SharpZipLib dll. And trying to unzip the Excel sheet of PPTX file and modifying the concerned xml files (excel) with the input data.

    Finally I am zipping the entire pptx and saving the file to my location. When trying to open the file, error has been generated, saying files are corrupted.

    Please view the sample Pseudo code

    Here TemplateResources.OpenXmlPPT is a PPTX file which resides in .resx,Which acts as a template

    ZipOutputStream(file): - file is a SaveDilaog stream object

    using (ZipOutputStream outputFile = new ZipOutputStream(file))

    {

    using (MemoryStream templateBuffer = new MemoryStream((TemplateResources.OpenXmlPPT)))

     {

         using (ZipInputStream templateFile = new ipInputStream(templateBuffer))

           {

               while ((ZipEntry entry = templateFile.GetNextEntry()) != null)

               {   

               if (String.Equals(entry.Name,"ppt/embeddings/Microsoft_Office_Excel_Worksheet1.xlsx", StringComparison.OrdinalIgnoreCase))

                    {

                               Here is the code for Unzip the xlsx sheet and modify the Conerned Xmls

                         if (String.Equals(Zpentry.Name, "xl/sharedStrings.xml", StringComparison.OrdinalIgnoreCase))

                         {

                               outputFile.Write(“”,””,"”);

                         }

                      }

               }

     }

     }

    }

    I have noticed that modified xml are not updated into exceel sheet with the help of ZipOutputStream . it couldn’t write those things into the exact loaction of the buffer.

    Please help in this regard.

Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.