Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3457882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:54:52+00:00 2026-05-18T09:54:52+00:00

We are trying to modify one of the XML files in 2007 MS Excel.

  • 0

We are trying to modify one of the XML files in 2007 MS Excel. For this, the xlsx file is being unzipped using Java’s ZipInputStream and then copied to a new Zip file using ZipOutputStream. The code snippets are as below :

        FileInputStream fis = new FileInputStream("C:\\_132139TRD-GDR_Conversion.xlsx");
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));

        FileOutputStream fos =  new FileOutputStream("C:\\_132139TRD-GDR_Conversion123.xlsx");
        ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));

        while ((entry = zis.getNextEntry()) != null) {

            System.out.println("Processing Entry : " + entry.getName());
            System.out.println("Processing Entry Size : " + entry.getSize());
            System.out.println("Entry Available : " + zis.available());

        if(entry.getName().equals(ZIP_ENTRY_WOOKBOOK_XML)){
          //Process XML
        }

        ZipEntry ze = new ZipEntry(entry.getName());
            zos.putNextEntry(ze);
            if(entry.getName().equals(ZIP_ENTRY_WOOKBOOK_XML)){
                    zos.write(XML.getBytes());
            }else{
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                while ((count = zis.read(data, 0, BUFFER)) != -1) {
                    stream.write(data, 0, count);
                }
                tempBuffer = stream.toByteArray();
                zos.write(tempBuffer);
            }
            zos.closeEntry();               
        }
        zos.close();
        fos.close();
        zis.close();
        fis.close();

In this snippet, after we encounter a JPEG file, the “entry = zis.getNextEntry()” returns null. We are not able to read the next ZipEntry – which leads to an incomplete Excel. The output for a sample Excel file is as below :

Start Date Mon Dec 06 15:33:33 IST 2010
Processing Entry : xl/media/Logo2005_JPM_A_Black_170x50.jpeg
Processing Entry Size : -1
Entry Available : 1
End Date Mon Dec 06 15:34:58 IST 2010

The ZipInputStream gets closed as soon as the JPEG file is copied. (entryEOF and reachEOF variables both turn true and entry is null after copying the image).

Has anybody faced a similar issue ? Is it a bug that reachEOF also turns true after copying the file ?

Midhun.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:54:53+00:00Added an answer on May 18, 2026 at 9:54 am

    This is because you read the data for the image from zis instead of from zis.getInputStream(entry).

    After the copy loop, all data from zis will have been read, so you get an EOF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to modify a proprietory XML file using XSL and MSXSL. The
I'm trying to modify this: jquery desktop by adding a input field inside one
I'm trying to modify the contents of an MSI file using Powershell. To do
Pretty new to sqlite (and sql). Trying to modify one table using another. create
I'm trying to modify the contents of one pointer using another. I want string2
Hello I am trying to modify one of the default files that comes with
I'm trying to modify this example to my needs, but one line in particular
I am trying to modify an existing WPF application for localization. One of my
This is someone elses code that I am trying to understand and modify... The
I'm trying to find some text in an XML file and delete only a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.