Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team,
i am trying to import excel sheet data to sql server..
sheet contains ItemName, Description and Image

Getting error while reading image from excel in c#

Error Code : Exception from HRESULT: 0x800A03EC

Here is my code

C#
if (dtItem.Rows[i]["PicName"].ToString() != "")
       {
           Worksheet sheet = worksheetItemOption;
           if (sheet != null)
            {
               string Pic = dtItem.Rows[i]["PicName"].ToString();
               Picture pict = sheet.Pictures(Pic) as Picture;
               pict.CopyPicture(XlPictureAppearance.xlScreen, XlCopyPictureFormat.xlBitmap);
             System.Drawing.Image img = Clipboard.GetImage();
             MemoryStream ms = new MemoryStream();
             img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
             byte[] bytes = ms.ToArray();
             postImportRequest.CommonMenu.Image = bytes;
            }


        }


Please help me
Thanks in advance
Posted
Comments
Herman<T>.Instance 16-Feb-15 8:37am    
Did you debug? I what line the error occurs?
.net333 16-Feb-15 8:38am    
Hi digimanus..getting error at Picture pict = sheet.Pictures(Pic) as Picture;
Kuthuparakkal 16-Feb-15 11:26am    
It may not be a picture.
aravinth santosh 19-Feb-15 11:41am    
check this condition
if (xlShape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture)
{
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900