日期:2014-05-17 浏览次数:20639 次
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
byte[] bytes = CustomerPhotoManager.GetPhoto(Convert.ToDecimal(dt.Rows[i]["PHOTO_ID"]));
MemoryStream ms = new MemoryStream(bytes);
//这里取出来的图片大小不是固定的
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
sheet.Cells.SetColumnWidth(6, 50);
sheet.Cells.SetRowHeight(i + 1, 195);
sheet.Cells[i + 1, 0].PutValue(dt.Rows[i]["CustomerCode"].ToString());
sheet.Cells[i + 1, 1].PutValue(dt.Rows[i]["CUSTOMER_NAME"].ToString());
sheet.Cells[i + 1, 2].PutValue(dt.Rows[i]["PHOTO_TYPE"].ToString());
sheet.Cells[i + 1, 3].PutValue(dt.Rows[i]["USER_NAME"].ToString());
sheet.Cells[i + 1, 4].PutValue(dt.Rows[i]["photo_date"].ToString());
sheet.Cells[i + 1, 5].PutValue(dt.Rows[i]["PHOTO_MEMO"].ToString());
sheet.Pictures.Add(i + 1, 6, ms); //这里绑定图片
sheet.Cells.SetColumnWidth(0, 20);
sheet.Cells.SetColumnWidth(1, 25);
sheet.Cells.SetColumnWidth(2, 25);
sheet.Cells.SetColumnWidth(3, 25);
sheet.Cells.SetColumnWidth(4, 25);
sheet.Cells.SetColumnWidth(5, 20);
}