使用 VBA 在 Excel 中绘制的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5196333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best way to draw in Excel using VBA?
提问by cmerrell
I'm a civil engineer designing a program that allows the user to define number of cross sections of a roadway and then calculate the quantity of the different materials used to build the roadway layers. I need to be able to plot a representation of the cross section that the users has defined. I'm not sure if this would be best accomplished by plotting various series on a chart, or drawing shape objects. Does anyone have any thoughts?
我是一名土木工程师,正在设计一个程序,该程序允许用户定义道路的横截面数量,然后计算用于构建道路层的不同材料的数量。我需要能够绘制用户定义的横截面的表示。我不确定这是否最好通过在图表上绘制各种系列或绘制形状对象来实现。有人有想法吗?
回答by Todd Main
Yeah, not only is Excel pretty good for this, it's also pretty common to use it for this. The Newton Excel Bach blog may be where you want to spend some good time - it's an Excel for engineerssite. He's got a great series on drawing with Excel. Here's one that addresses your immediate question: Drawing in Excel 7 – Creating drawings from coordinates
是的,Excel 不仅在这方面非常好,而且在这方面使用它也很常见。Newton Excel Bach 博客可能是您想要度过一段美好时光的地方 - 这是一个Excel 工程师站点。他有一个关于用 Excel 绘图的精彩系列。这是一个解决您当前问题的方法:在 Excel 7 中绘图 – 从坐标创建绘图
回答by Andrew Cowenhoven
Since I know nothing about your problem domain or your programming skills, I can only give some general thoughts:
由于我对你的问题领域或你的编程技巧一无所知,我只能给出一些一般性的想法:
Excel is really good for modeling and building certain prototypes. Modeling this problem and building some charts by hand should give you and your users a good idea if the Excel solution is going to fly. If you can't get the graphics you want I would look elsewhere. Perhaps Visual Studio and Visual Basic or C#. These have mature drawing capabilities and also charting controls in recent editions.
Excel 非常适合建模和构建某些原型。对此问题建模并手动构建一些图表应该可以让您和您的用户了解 Excel 解决方案是否会奏效。如果你不能得到你想要的图形,我会去别处看看。也许 Visual Studio 和 Visual Basic 或 C#。这些具有成熟的绘图功能和最新版本的图表控件。
Excel VBA has a pretty good programming layer for charts. You can also draw custom objects with VBA. I have not done this but I am sure there are references on the web. In any event, if the manually built Excel prototype looks good, it might be worthwhile to automate it with VBA.
Excel VBA 有一个非常好的图表编程层。您还可以使用 VBA 绘制自定义对象。我没有这样做,但我确信网上有参考资料。无论如何,如果手动构建的 Excel 原型看起来不错,那么使用 VBA 将其自动化可能是值得的。
Another factor is how many, and of what skill set will the users be? Fewer users, who know Excel pretty well make a case for using Excel. Supporting a large number of users could become onerous as it is possible to change the code in an individual file.
另一个因素是用户的数量和技能组合是什么?对 Excel 非常了解的用户较少,因此会推荐使用 Excel。支持大量用户可能会变得繁重,因为可以更改单个文件中的代码。
Finally, how long will this application be around? Versioning Excel applications can be done, but it easier to do this with more sophisticated programming environments. Also if you are going to continue to add features you might run into a wall with VBA's feature set. Hope this helps.
最后,这个应用程序会持续多久?可以对 Excel 应用程序进行版本控制,但使用更复杂的编程环境更容易做到这一点。此外,如果您打算继续添加功能,您可能会遇到 VBA 功能集的障碍。希望这可以帮助。