Hi all,
When I insert secord picture in Xlsx file, it always replace first one.
Any help?
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet1 = workbook.CreateSheet("PictureSheet");
IDrawing patriarch = sheet1.CreateDrawingPatriarch();
//create the anchor
XSSFClientAnchor anchor = new XSSFClientAnchor(500, 200, 0, 0, 2, 2, 4, 7);
anchor.AnchorType = 2;
//load the picture and get the picture index in the workbook
XSSFPicture picture = (XSSFPicture)patriarch.CreatePicture(anchor, LoadImage("../../image/HumpbackWhale.jpg", workbook));
picture.Resize(); //Note: Resize will reset client anchor you set.
XSSFClientAnchor anchor2 = new XSSFClientAnchor(500, 200, 0, 0, 12, 2, 14, 7);
anchor2.AnchorType = 2;
XSSFPicture picture2 = (XSSFPicture)patriarch.CreatePicture(anchor2, LoadImage("../../image/pic2.jpg", workbook));
picture2.Resize();
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
Comments: ** Comment from web user: CharlotW **
When I insert secord picture in Xlsx file, it always replace first one.
Any help?
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet1 = workbook.CreateSheet("PictureSheet");
IDrawing patriarch = sheet1.CreateDrawingPatriarch();
//create the anchor
XSSFClientAnchor anchor = new XSSFClientAnchor(500, 200, 0, 0, 2, 2, 4, 7);
anchor.AnchorType = 2;
//load the picture and get the picture index in the workbook
XSSFPicture picture = (XSSFPicture)patriarch.CreatePicture(anchor, LoadImage("../../image/HumpbackWhale.jpg", workbook));
picture.Resize(); //Note: Resize will reset client anchor you set.
XSSFClientAnchor anchor2 = new XSSFClientAnchor(500, 200, 0, 0, 12, 2, 14, 7);
anchor2.AnchorType = 2;
XSSFPicture picture2 = (XSSFPicture)patriarch.CreatePicture(anchor2, LoadImage("../../image/pic2.jpg", workbook));
picture2.Resize();
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
Comments: ** Comment from web user: CharlotW **
have u solve the error?