您的位置:程序门 -> .net技术 -> c#



关于从sql数据库image字段中读取excel文件


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于从sql数据库image字段中读取excel文件
发表于: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文件的公式和格式部门丢失,而文字部分正常。


发表于:2007-03-30 09:53:281楼 得分:0
up
发表于:2007-05-09 10:51:522楼 得分:0
up
发表于:2007-05-09 11:13:143楼 得分:0
难,我帮你顶


快速检索

最新资讯
热门点击