public PictureInfo(int minRow, int maxRow, int minCol, int maxCol, Byte[] pictureData, PictureStyle pictureStyle) { this.MinRow = minRow; this.MaxRow = maxRow; this.MinCol = minCol; this.MaxCol = maxCol; this.PictureData = pictureData; this.PicturesStyle = pictureStyle; }
private static List <PictureInfo> GetAllPictureInfos(XSSFSheet sheet, int?minRow, int?maxRow, int?minCol, int?maxCol, bool onlyInternal) { List <PictureInfo> picturesInfoList = new List <PictureInfo>(); var documentPartList = sheet.GetRelations(); foreach (var documentPart in documentPartList) { if (documentPart is XSSFDrawing) { var drawing = (XSSFDrawing)documentPart; var shapeList = drawing.GetShapes(); foreach (var shape in shapeList) { if (shape is XSSFPicture) { var picture = (XSSFPicture)shape; var anchor = picture.GetPreferredSize(); if (IsInternalOrIntersect(minRow, maxRow, minCol, maxCol, anchor.Row1, anchor.Row2, anchor.Col1, anchor.Col2, onlyInternal)) { var picStyle = new PictureStyle { AnchorDx1 = anchor.Dx1, AnchorDx2 = anchor.Dx2, AnchorDy1 = anchor.Dy1, AnchorDy2 = anchor.Dy2, IsNoFill = picture.IsNoFill, LineStyle = picture.LineStyle, LineStyleColor = picture.LineStyleColor, LineWidth = picture.LineWidth, FillColor = picture.FillColor }; picturesInfoList.Add(new PictureInfo(anchor.Row1, anchor.Row2, anchor.Col1, anchor.Col2, picture.PictureData.Data, picStyle)); } } } } } return(picturesInfoList); }
private static List <PictureInfo> GetAllPictureInfos(HSSFSheet sheet, int?minRow, int?maxRow, int?minCol, int?maxCol, bool onlyInternal) { List <PictureInfo> picturesInfoList = new List <PictureInfo>(); var shapeContainer = sheet.DrawingPatriarch as HSSFShapeContainer; if (null != shapeContainer) { var shapeList = shapeContainer.Children; foreach (var shape in shapeList) { if (shape is HSSFPicture && shape.Anchor is HSSFClientAnchor) { var picture = (HSSFPicture)shape; var anchor = (HSSFClientAnchor)shape.Anchor; if (IsInternalOrIntersect(minRow, maxRow, minCol, maxCol, anchor.Row1, anchor.Row2, anchor.Col1, anchor.Col2, onlyInternal)) { var picStyle = new PictureStyle { AnchorDx1 = anchor.Dx1, AnchorDx2 = anchor.Dx2, AnchorDy1 = anchor.Dy1, AnchorDy2 = anchor.Dy2, IsNoFill = picture.IsNoFill, LineStyle = picture.LineStyle, LineStyleColor = picture.LineStyleColor, LineWidth = picture.LineWidth, FillColor = picture.FillColor }; picturesInfoList.Add(new PictureInfo(anchor.Row1, anchor.Row2, anchor.Col1, anchor.Col2, picture.PictureData.Data, picStyle)); } } } } return(picturesInfoList); }