首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C# Arcobjects:将Excel插入分页

C# Arcobjects:将Excel插入分页
EN

Stack Overflow用户
提问于 2017-12-22 13:56:32
回答 1查看 302关注 0票数 0

我正在寻找如何将excel工作表添加到mxd的分页中的方向;非常类似于通过arcmap接口提供的函数。

我正在使用C# arcobjects (10.5),并且讨厌内存中的MXD。那时,我将excel添加到页面中,然后导出为PDF。

我已经厌倦了下面的内容,但是当我转换'rawSrc‘变量时,它是空的。我不知道什么是正确的IElement类型:

代码语言:javascript
复制
 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);

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2017-12-22 14:25:05

将真实的工作表名称写入Excel。如果工作表名为"sheet1“,您应该写上;

var rawSrc =新XLWorkbook(xcelPath).Worksheet("sheet1");

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47942721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档