× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have been hunting around the Net for a solution and I have wondered if translation was an issue. I don't specifically translate anything I know of. Once the spreadsheet is created the getSpreadSheet method does the following:

public byte[] getSpreadSheet(String sheetname, UserContainer userContainer) throws IOException{
String userId = userContainer.getDaoContainer().getUserId();
String filePath = _spreadsheetPath + userId.trim();
byte[] outFile = null;
// We'll need some logic to use either the AS400 routines or the
// regular file utility
if(_i5os) // properties value
outFile = AS400FileUtility.downloadFile(userContainer.getDaoContainer(), filePath, sheetname);
else
outFile = FileUtility.downloadFile(filePath, sheetname);

return ourFile;
}

I originally thought the issue was here because the downloadFile method would use the AS400FileUtility class and it could account for the difference I was seeing when things ran on the System i vs on my notebook, but after the new war deployed to Tomcat (5.0.28) , both the System i and my local notebook produce a bad excel file.

FWIW the downloadFile method is:

public static byte[] downloadFile(String filepath, String filename) throws IOException {
FileInputStream source = null;
try {
String sourceName = filepath + File.separator + filename;
// Path and file should have been created by spreadsheet builder
// which puts the file into the folder. We are just retrieving it here

source = new FileInputStream(sourceName);
int available = source.available();
System.out.println("Source file successfully opened");

byte[] buffer = new byte[available];

//int bytesread = source.read(buffer);
//System.out.println("Bytes read:" + bytesread);

return buffer;

} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
if (source != null)
source.close();

}
}

Not being a "raw" file reader, how would I go about "comparing the hex values"?

Thanks

Pete



Scott Klement wrote:
Hi Pete,

Excel files are binary documents -- they contain lots of non-text data. With that in mind, is it possible that somewhere along the line the system is trying to translate your Excel document from one CCSID to another?

We commonly expect this behavior with i5/OS applications, because we work so much in EBCDIC text, and the PC wants ASCII text, so we want the operating system to "automatically" translate the document. But in the case of an Excel spreadsheet, it's very important that no translation takes place.

Does the getSpreadSheet() method do any translation? (Any at all... doesn't have to be ASCII to EBCDIC... translating ASCII to Unicode would corrupt the file as well).

Does the BufferedOutputStream do any translation?

Does the HTTP server (I assume you're using Tomcat or WebSphere) do any translation?

Obviously, you want to make sure that nothing gets translated.

If all else fails, maybe you could compare the hex values of the data that the browser receives with the hex values of the data of the file in the folder. If one works and the other fails, then they must be different. If so, what's the difference? That would give you a good idea of where to look for the problem.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.