using System; using System.Collections.Generic; using System.Text; using System.IO; using QiHe.CodeLib; using HH.WMS.Utils.ExcelLibrary.BinaryFileFormat; using HH.WMS.Utils.ExcelLibrary.BinaryDrawingFormat; namespace HH.WMS.Utils.ExcelLibrary.SpreadSheet { public class Worksheet { public Workbook Book; public string Name; public SheetType SheetType; public MSODRAWING Drawing; public CellCollection Cells; internal Worksheet() { } public Worksheet(string name) { this.Name = name; this.Cells = new CellCollection(); } bool extracted = false; Dictionary, Picture> pictures = new Dictionary, Picture>(); public Dictionary, Picture> Pictures { get { if (!extracted) { ExtractPictures(); extracted = true; } return pictures; } } public Picture ExtractPicture(int row, int col) { Pair pos = new Pair(row, col); if (Pictures.ContainsKey(pos)) { return Pictures[pos]; } else { return null; } } public void AddPicture(Picture pic) { pictures[pic.CellPos] = pic; } public void ExtractPictures() { if (Drawing != null) { MsofbtDgContainer dgContainer = Drawing.FindChild(); if (dgContainer != null) { MsofbtSpgrContainer spgrContainer = dgContainer.FindChild(); List spContainers = spgrContainer.FindChildren(); foreach (MsofbtSpContainer spContainer in spContainers) { MsofbtOPT opt = spContainer.FindChild(); MsofbtClientAnchor anchor = spContainer.FindChild(); if (opt != null && anchor != null) { foreach (ShapeProperty prop in opt.Properties) { if (prop.PropertyID == PropertyIDs.BlipId) { int imageIndex = (int)prop.PropertyValue - 1; Picture pic = new Picture(); pic.TopLeftCorner.RowIndex = anchor.Row1; pic.TopLeftCorner.ColIndex = anchor.Col1; pic.TopLeftCorner.DX = anchor.DX1; pic.TopLeftCorner.DY = anchor.DY1; pic.BottomRightCorner.RowIndex = anchor.Row2; pic.BottomRightCorner.ColIndex = anchor.Col2; pic.BottomRightCorner.DX = anchor.DX2; pic.BottomRightCorner.DY = anchor.DY2; pic.Image = Book.ExtractImage(imageIndex); pictures[pic.CellPos] = pic; break; } } } } } } } } }