Either XLSX file is bad or J# has a bug...

D

David Thielen

I don't know if this is an Excel bug or a J# bug (or both). The XLSX file
(which is a zip file) at http://www.windwardreports.com/temp/BadXlsx.zip
throws a ZipException (extra read failure) when reading the files using the
following code (on entry 14 of 18):

ZipInputStream zis = new ZipInputStream(in);

ZipEntry ze;

byte data[] = new byte[BUFFER_SIZE];

docxFiles = new ArrayList();

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

if (! ze.isDirectory()) {

String entryName = ze.getName();

ByteArrayOutputStream destData = new ByteArrayOutputStream();

int len;

while ((len = zis.read(data, 0, BUFFER_SIZE)) != -1)

destData.write(data, 0, len);

destData.flush();

docxFiles.add(new DocxFile(entryName, destData.toByteArray()));

destData.close();

}

zis.closeEntry();

}

zis.close();



Any idea what is going on and what the work-around is? The XLSX file was
created with Excel 2003 using the MS AddIn to read/write XLSX files. WinZip
can open the file with no problem.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

I have tested your code and the xlsx file:

import java.util.zip.*;
import java.io.*;
import java.util.*;

public static void main(String[] args)
{
try
{
String inFilename = "Path to BadXlsx.zip";

FileInputStream in = new FileInputStream(inFilename);
ZipInputStream zis = new ZipInputStream(in);
ZipEntry ze;
byte data[] = new byte[1024];

ArrayList docxFiles = new ArrayList();

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

if (!ze.isDirectory())
{
String entryName = ze.getName();
ByteArrayOutputStream destData = new ByteArrayOutputStream();
int len;
while ((len = zis.read(data, 0, 1024)) != -1)
destData.write(data, 0, len);
destData.flush();
destData.toByteArray();
//docxFiles.add(new DocxFile(entryName, destData.toByteArray()));
destData.close();
}
zis.closeEntry();
}
zis.close();
}
catch (Exception ex)
{
}
}

However, the test project above works well without any exception. Would you
try it in your side and let me know the result? Would you let me know the
line of code that throws the exception?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Very weird - that works. But the same code called inside our engine fails. We
switched to SharpZipLib so we're working now so call this closed.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Jialiang Ge said:
Hello Dave,

I have tested your code and the xlsx file:

import java.util.zip.*;
import java.io.*;
import java.util.*;

public static void main(String[] args)
{
try
{
String inFilename = "Path to BadXlsx.zip";

FileInputStream in = new FileInputStream(inFilename);
ZipInputStream zis = new ZipInputStream(in);
ZipEntry ze;
byte data[] = new byte[1024];

ArrayList docxFiles = new ArrayList();

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

if (!ze.isDirectory())
{
String entryName = ze.getName();
ByteArrayOutputStream destData = new ByteArrayOutputStream();
int len;
while ((len = zis.read(data, 0, 1024)) != -1)
destData.write(data, 0, len);
destData.flush();
destData.toByteArray();
//docxFiles.add(new DocxFile(entryName, destData.toByteArray()));
destData.close();
}
zis.closeEntry();
}
zis.close();
}
catch (Exception ex)
{
}
}

However, the test project above works well without any exception. Would you
try it in your side and let me know the result? Would you let me know the
line of code that throws the exception?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Top