版主:请教,单元格第一行显示的图片和数据库存入的图片不一致?
//显示图片
SqlStr = "Select A.[NoteNo] as 申请单号,A.SubNoteNo as 子号,B.ProjectName as 项目单位,B.Content as 项目内容,";
SqlStr = SqlStr + "A.AppendixType as 附件类型,A.Remarks as 说明, A.[FileType] as 文件类型,A.[FileTitle] as 文件标题,A.NoteFile as 图片 ";
SqlStr = SqlStr + " FROM [PurchaseApplyFile] A ,PurchaseApply B ";
SqlStr = SqlStr + " where A.NoteNo=B.NoteNo and A.NoteNo='"+ TxtNoteNo .Text +"' Order By A.NoteNo,A.SubNoteNo ";
Da = new SqlDataAdapter(SqlStr, Sqlcon);
Ds = new DataSet();
Da.Fill(Ds, "PurchaseApplyFile");
if (Ds.Tables[0].Rows.Count > 0)
{
FpSpreadFile.DataSource = Ds.Tables[0];
FpSpreadFile.DataBind();
FpSpreadFile.Sheets[0].Columns[8].Width = 200;
for (int I = 0; I < Ds.Tables[0].Rows.Count; I++)
{
//string FileType = Ds.Tables[0].Rows[I][6].ToString ();
if (Convert .ToString ( Ds.Tables [0].Rows[I][6].ToString ())=="image/jpeg")
{
byte[] photo = new byte[0];
photo = (byte[])Ds.Tables[0].Rows[I][8];
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap bm = (Bitmap)tc.ConvertFrom(photo);
string FileName = "~/Image/Image" + (I + 1).ToString() + ".jpg";
if (File.Exists(FileName))
{
try
{
File.Delete(FileName);
}
catch (Exception ex)
{
throw ex;
}
}
bm.Save(Server.MapPath(FileName));
FpSpreadFile.ActiveSheetView.Cells[I, 8].Value = null;
FarPoint.Web.Spread.ImageCellType ict = new FarPoint.Web.Spread.ImageCellType();
FpSpreadFile.ActiveSheetView.Cells[I, 8].CellType = ict;
ict.TextOnRight = false;
ict.ImageAlign = ImageAlign.AbsMiddle;
//ict.ImageUrl = "~/Image/Image" + (I + 1).ToString() + ".jpg";
ict.ImageUrl = FileName;
ict.CssClass = "test";
}
}
}
FpSpreadFile.SaveChanges();
Ds.Dispose();
Da.Dispose();
|
-
|