mxd의 pagelayout에 엑셀 시트를 추가하는 방법에 대한 지침을 찾고 있습니다. arcmap 인터페이스를 통해 사용할 수있는 기능과 매우 유사합니다.C# Arcobjects : pagelayout에 Excel 객체 삽입
저는 C# arcobjects (10.5)를 사용 중이며 MXD를 메모리에 loaing하고 있습니다. 그때 나는 pagelayout에 Excel을 추가 한 다음 PDF로 내보내는 중입니다.
나는 아래를 피곤하지만 'rawSrc'변수를 캐스팅하면 null입니다. 나는 올바른 인 IElement 유형이 무엇인지 확실하지 않다 : 도움을
IPageLayout pageLayout = myMXD.PageLayout;
IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
RectangleElement ExcelSrc = new RectangleElement();
double posX = 0.8008;
double posY = 6.9567;
double Legwidth = 4.8;
System.Double w = 11.0301;
System.Double h = 9.0949;
System.Double aspectRatio = w/h;
var envelope = new EnvelopeClass();
envelope.PutCoords(posX, posY, (posX * Legwidth), (posY * Legwidth/aspectRatio));
ExcelSrc.Geometry = envelope;
string xcelPath = System.IO.Path.Combine("string to my directory", "Data.xlsx");
var rawSrc = new XLWorkbook(xcelPath).Worksheet("Table");
IVariantStream blobStream = new VariantStreamIOClass();
blobStream = rawSrc as IVariantStream;
ExcelSrc = blobStream.Read() as RectangleElement;
graphicsContainer.AddElement(((IElement)ExcelSrc), 0);
((IActiveView)myMXD.PageLayout).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
myMXD.Save();
Marshal.FinalReleaseComObject(blobStream);
감사합니다.
"하지만 캐스트했을 때 null입니다."무엇을 캐스트합니까? 당신은 어디에서'null '을 얻습니까? – HimBromBeere
@HimBromBeere 죄송합니다. 나는 그 게시물을 더 명확하게 업데이트했다. – Arnej65