我正在寻找如何将excel工作表添加到mxd的分页中的方向;非常类似于通过arcmap接口提供的函数。
我正在使用C# arcobjects (10.5),并且讨厌内存中的MXD。那时,我将excel添加到页面中,然后导出为PDF。
我已经厌倦了下面的内容,但是当我转换'rawSrc‘变量时,它是空的。我不知道什么是正确的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);谢谢你的帮助。
发布于 2017-12-22 14:25:05
将真实的工作表名称写入Excel。如果工作表名为"sheet1“,您应该写上;
var rawSrc =新XLWorkbook(xcelPath).Worksheet("sheet1");
https://stackoverflow.com/questions/47942721
复制相似问题