Can`t put picture in worksheet

Sep 17, 2009 at 4:46 PM

hi,

   Im a newbiee whith NPOI and having problems while inserting image of top left corner of sheet, i was looking for many examples and worte this:

                //----------------------------------
                HSSFPatriarch patriarch = sheet1.CreateDrawingPatriarch();
                HSSFClientAnchor anchor = new HSSFClientAnchor();
                int pictureIdx = 0;
                using (FileStream fs = new FileStream(@"c:\imgTest.jpg", FileMode.Open))
                {
                    byte[] bytes = new byte[fs.Length];
                    fs.Write(bytes, 0, (int)fs.Length);
                    pictureIdx = wrkBk.AddPicture(bytes, HSSFWorkbook.PICTURE_TYPE_JPEG);
                }
                HSSFPicture picture = patriarch.CreatePicture(anchor, pictureIdx);
                //picture.Resize(); // throw invalid parameter if uncomment
                //----------------------------------
                MemoryStream stream = new MemoryStream();
                wrkBk.Write(stream);
                return stream.GetBuffer();
                //----------------------------------

       above this code i create the workbook and populate whith data, when i open the generated excel file all data is there but i receive a error whith the mesage(in portuguese, my translation may no not exacly the same) "File Error: Data May Have been Lost" and whithout the image i put in the top left corner near first cell. I probably doing some stupid in this code but what ?

      Another doubt, how can i set filters in columns ?

 

Thanks a lot.

Sep 24, 2009 at 1:22 AM

 

hello
  In my project I have the same problem, no image appears, have tried lots of examples and i was received the same error message.
Best regards

hello

  In my project I have the same problem, no image appears, have tried lots of examples and i was received the same error message.

Best regards