Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Created Unassigned: Using npoi add pictures to excel [13086]

$
0
0
Hi All,
First, forgive my poor English. Here I have a problem, I have two pictures, and I want to insert into one sheet
of a Excel. but the result is it always display the last create picture. below is my C# code. If anybody can help, thanks.

//------------------------------
byte[] bytes1 = System.IO.File.ReadAllBytes("First picture");
int pictureIdx1 = workbook.AddPicture(bytes1, NPOI.SS.UserModel.PictureType.JPEG);

byte[] bytes2 = System.IO.File.ReadAllBytes("Second picture");
int pictureIdx2 = workbook.AddPicture(bytes2, NPOI.SS.UserModel.PictureType.JPEG);

sheet = workbook.GetSheet("Sheet1");
NPOI.SS.UserModel.IDrawing patriarch = sheet.CreateDrawingPatriarch();

NPOI.SS.UserModel.IClientAnchor anchor = new NPOI.XSSF.UserModel.XSSFClientAnchor(0, 0, 23, 0, 0, 1, 5, 5);
patriarch.CreatePicture(anchor, pictureIdx1);

anchor = new NPOI.XSSF.UserModel.XSSFClientAnchor(0, 0, 23, 0, 0, 15, 5, 18);
patriarch.CreatePicture(anchor, pictureIdx2);

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>