将照片格式进行转换后,问题已解决!
更正后代码如下:
if (File.Exists(dt.Rows[iRow][iCol].ToString()))
{
System.Drawing.Image image = System.Drawing.Image.FromFile(dt.Rows[iRow][iCol].ToString());
Bitmap bmp = new Bitmap(image);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Image NewImage = Image.FromStream(ms);
dgv.Sheets[0].Cells[iRow, iCol].Value = NewImage;
dgv.Sheets[0].Rows[iRow].Height = 50;
image.Dispose();
}
更正后数据文件20-30M左右,下载完全没有问题,且速度很快~ |