使用的是网上下载的经过改写的dsoframer2.3.0.0.
客户端装载fc.open('http://localhost/UserID/temp/aa.xls',true,"Excel.Sheet")都没有问题。
通过javascript如下:
function save_spec_form(frameControl1,fileName,processUrl){
var fc = document.getElementById(frameControl1);
if(fc){
fc.HttpInit();
fc.ProtectDoc(1,1,"pwd");
fc.HttpAddPostCurrFile("FileData",fileName);
fc.HttpPost(processUrl);
}
}
提交到服务器端后通过JSP文件进行接收。
接收页面如下:
String filepath = "c:\\temp\aa.xls";
InputStream is = request.getInputStream();
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
byte[] tempbytes = new byte[512];
while (is.read(tempbytes) != -1){
bytestream.write(tempbytes);
}
byte[] source_bin = bytestream.toByteArray();
//测试输出XLS文件
System.out.print("Modify by Yuanjun 20090927");
FileOutputStream fosT = null;
fosT = new FileOutputStream("d:\\temp\\testxls.xls");
fosT.write(source_bin, 0, source_bin.length);
fosT.close();
System.out.print("source_bin:"+source_bin.length);
//
bytestream.close();
int tLen = source_bin.length;//总长度
int i, loop, again = -1;
//String saveFileName = "";
for (i = 0; i < tLen; i++){
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
break;
}
//MyHeaderEnd标记
String MyHeaderEnd = "Content-Type: application/vnd.ms-excel";
byte[] MyHeader = MyHeaderEnd.getBytes();
//MyBooterEnd标记
String MyBooterEnd = "----MULTI-PARTS-FORM-DATA-BOUNDARY--";
byte[] MyBooter = MyBooterEnd.getBytes(); for (i += 2; i < tLen; i++)
{
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
if (source_bin[i + 2] == 13)
if (source_bin[i + 3] == 10)
break;
} int iFNStart = i + 4;
int iFNEnd = 0;
for (i += 4; i < tLen; i++){
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
break;
}
iFNEnd = i;
for (i = 0; i < tLen; i++)
{
//System.out.println("i:"+i);
for (loop = 0; loop < MyHeader.length; loop++){
//System.out.println("loop:"+loop);
if (source_bin[i + loop] != MyHeader[loop])
break;
}
if (loop >= MyHeader.length)
{
break;
}
}
//剔除换行
for (i += MyHeader.length; i < tLen; i++)
{
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
if (source_bin[i + 2] == 13){
if (source_bin[i + 3] == 10){
i += 4;
break;
}
}else{
i += 2;
}
}
//System.out.println(new String(MyHeader));
//System.out.println("当前Offset:"+i);
byte[] bXlsFile = new byte[tLen - i];
int tlen2 = bXlsFile.length;
for(int j = 0; j < tLen - i; j++){
bXlsFile[j] = source_bin[j + i];
}
//剔除MyBooter
boolean bHas = false;
for (i = 0; i < tlen2; i++)
{
//System.out.println("i:"+i);
for (loop = 0; loop < MyBooter.length; loop++){
//System.out.println("loop:"+loop);
if (bXlsFile[i + loop] != MyBooter[loop])
break;
}
if (loop >= MyBooter.length)
{
bHas = true;
break;
}
}
byte[] bXlsFile2 = new byte[0];
if (bHas){
bXlsFile2 = new byte[i - MyBooter.length];
for(int j = 0; j < i - MyBooter.length; j++){
bXlsFile2[j] = bXlsFile[j];
}
}else{
bXlsFile2 = new byte[i];
for(int j = 0; j < i; j++){
bXlsFile2[j] = bXlsFile[j];
}
} File checkFile = new File(filepath);
if(checkFile.exists()){
checkFile.delete();
}
FileOutputStream fos = null;
fos = new FileOutputStream(filepath);
byte[] sb = new byte[512];
for(int i1=0,j1=0;i1 <bXlsFile2.length;i1++,j1++){
sb[j1]=bXlsFile2[i1];
if(i1==bXlsFile2.length-1){
fos.write(sb);
break;
}
if(j1==511){
j1=-1;
fos.write(sb);
}
}
fos.close();
}catch(Exception e){
e.printStackTrace();
} 现在的问题是接收到的excel文件,经过几次重复的打开(并不做修改)上传之后,dsoframer就不能打开此文件了,通过比较生成的多次的excel文件,发现文件大小在变化,如果文件大小无变化,能正常打开,如果文件大小变化了,dsoframer就无法打开了。
哪些兄弟做过的,给个建议或解决方案啊,先谢了。
项目紧急啊,急盼回复。
客户端装载fc.open('http://localhost/UserID/temp/aa.xls',true,"Excel.Sheet")都没有问题。
通过javascript如下:
function save_spec_form(frameControl1,fileName,processUrl){
var fc = document.getElementById(frameControl1);
if(fc){
fc.HttpInit();
fc.ProtectDoc(1,1,"pwd");
fc.HttpAddPostCurrFile("FileData",fileName);
fc.HttpPost(processUrl);
}
}
提交到服务器端后通过JSP文件进行接收。
接收页面如下:
String filepath = "c:\\temp\aa.xls";
InputStream is = request.getInputStream();
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
byte[] tempbytes = new byte[512];
while (is.read(tempbytes) != -1){
bytestream.write(tempbytes);
}
byte[] source_bin = bytestream.toByteArray();
//测试输出XLS文件
System.out.print("Modify by Yuanjun 20090927");
FileOutputStream fosT = null;
fosT = new FileOutputStream("d:\\temp\\testxls.xls");
fosT.write(source_bin, 0, source_bin.length);
fosT.close();
System.out.print("source_bin:"+source_bin.length);
//
bytestream.close();
int tLen = source_bin.length;//总长度
int i, loop, again = -1;
//String saveFileName = "";
for (i = 0; i < tLen; i++){
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
break;
}
//MyHeaderEnd标记
String MyHeaderEnd = "Content-Type: application/vnd.ms-excel";
byte[] MyHeader = MyHeaderEnd.getBytes();
//MyBooterEnd标记
String MyBooterEnd = "----MULTI-PARTS-FORM-DATA-BOUNDARY--";
byte[] MyBooter = MyBooterEnd.getBytes(); for (i += 2; i < tLen; i++)
{
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
if (source_bin[i + 2] == 13)
if (source_bin[i + 3] == 10)
break;
} int iFNStart = i + 4;
int iFNEnd = 0;
for (i += 4; i < tLen; i++){
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
break;
}
iFNEnd = i;
for (i = 0; i < tLen; i++)
{
//System.out.println("i:"+i);
for (loop = 0; loop < MyHeader.length; loop++){
//System.out.println("loop:"+loop);
if (source_bin[i + loop] != MyHeader[loop])
break;
}
if (loop >= MyHeader.length)
{
break;
}
}
//剔除换行
for (i += MyHeader.length; i < tLen; i++)
{
if (source_bin[i] == 13)
if (source_bin[i + 1] == 10)
if (source_bin[i + 2] == 13){
if (source_bin[i + 3] == 10){
i += 4;
break;
}
}else{
i += 2;
}
}
//System.out.println(new String(MyHeader));
//System.out.println("当前Offset:"+i);
byte[] bXlsFile = new byte[tLen - i];
int tlen2 = bXlsFile.length;
for(int j = 0; j < tLen - i; j++){
bXlsFile[j] = source_bin[j + i];
}
//剔除MyBooter
boolean bHas = false;
for (i = 0; i < tlen2; i++)
{
//System.out.println("i:"+i);
for (loop = 0; loop < MyBooter.length; loop++){
//System.out.println("loop:"+loop);
if (bXlsFile[i + loop] != MyBooter[loop])
break;
}
if (loop >= MyBooter.length)
{
bHas = true;
break;
}
}
byte[] bXlsFile2 = new byte[0];
if (bHas){
bXlsFile2 = new byte[i - MyBooter.length];
for(int j = 0; j < i - MyBooter.length; j++){
bXlsFile2[j] = bXlsFile[j];
}
}else{
bXlsFile2 = new byte[i];
for(int j = 0; j < i; j++){
bXlsFile2[j] = bXlsFile[j];
}
} File checkFile = new File(filepath);
if(checkFile.exists()){
checkFile.delete();
}
FileOutputStream fos = null;
fos = new FileOutputStream(filepath);
byte[] sb = new byte[512];
for(int i1=0,j1=0;i1 <bXlsFile2.length;i1++,j1++){
sb[j1]=bXlsFile2[i1];
if(i1==bXlsFile2.length-1){
fos.write(sb);
break;
}
if(j1==511){
j1=-1;
fos.write(sb);
}
}
fos.close();
}catch(Exception e){
e.printStackTrace();
} 现在的问题是接收到的excel文件,经过几次重复的打开(并不做修改)上传之后,dsoframer就不能打开此文件了,通过比较生成的多次的excel文件,发现文件大小在变化,如果文件大小无变化,能正常打开,如果文件大小变化了,dsoframer就无法打开了。
哪些兄弟做过的,给个建议或解决方案啊,先谢了。
项目紧急啊,急盼回复。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货