| 发表于:2007-03-28 15:09:05 楼主 |
各位高手,在下在读取sql数据库中的image字段生成excel文件时遇到困难,请帮忙解决。 1.表结构: 表名:attachfiles 表结构:id,filename(文件名),filebody(文件主体) 2.读取代码: //读数据 datarow dr = ds.tables[0].rows[id]; string filename = dr[ "filename "].tostring(); byte[] mydata= new byte[0]; mydata = (byte[])dr[ "filebody "]; int arraysize = new int(); arraysize = mydata.getupperbound(0); string tempdir = @ "c:\ "; string tempfile = tempdir+filename; //写入文件 filestream fs = new filestream(tempfile.trim(), filemode.openorcreate, fileaccess.write); fs.write(mydata, 0,arraysize); fs.close(); //打开文件 system.diagnostics.process.start(tempfile.trim()); 3.问题: 在读取.doc,.bmp,.jpg文件时多正常。在读取excel文件时报如下错误: 1.excel无法使用 "*.* "(此处文文件名),可能是因为这个档案是唯读的,或则存放它的地方是唯读的,或是伺服器没有回应。 2.microsoft office excel 檔案修復報表 檔案 'c:\12月份供應商交貨時間.xls ' 中偵測出錯誤修補清單如下: 檔案因嚴重損毀而無法修復。excel 已嘗試復原您的公式及值,但某些資料可能已經遺失或損毀。 3.打开的excel文件的公式和格式部门丢失,而文字部分正常。 |
|
|
|
|