C#/Powerpoint 插件 如何将 datagridview 保存到演示文稿中?

发布于 2024-12-25 07:57:30 字数 444 浏览 1 评论 0原文

所以我一直在研究这个ppt插件。我主要使用标签哈希来保存字符串,到目前为止效果很好;但是,现在我需要将 2D 数组保存到演示文稿中。我选择使用 datagridview 组件并将其放置在新表单中。

一旦用户输入他的数据并且表单准备关闭,我不知道在哪里保存网格。我本质上想稍后将其作为某种二维数组进行访问(可能有更简单的方法来访问此数据);但是,首先我需要以某种方式将其保存到演示文稿中。

powerpoint是否只是序列化整个演示对象并完全保存它?在这种情况下,我可以做类似的事情:

PowerPoint.Presentation preso = Globals.ThisAddIn.Application.ActivePresentation;
preso.myGrid = theGridViewFromTheForm;

或者类似的事情吗?

有想法吗?

So I have been working on this ppt add-in. I have been saving strings mostly using the tags hash and it has worked fine thus far; however, now I need to essentially save a 2D array to the presentation. I chose the use the datagridview component and placed it in a new form.

Once the user inputs his data and the form is ready to close I have no idea where to save the grid. I essentially would like to access it later as a 2D array of some sort (there are probably easier ways to access this data); however, first I need to save it to the presentation some how.

Does powerpoint just serialize the entire presentation object and save it entirely? In this case can I just do something like:

PowerPoint.Presentation preso = Globals.ThisAddIn.Application.ActivePresentation;
preso.myGrid = theGridViewFromTheForm;

Or something along those lines?

Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

路弥 2025-01-01 07:57:30

我只是使用标签保存了所有内容。我想你可以用其他不那么明显的方式来保存东西。

I simply saved everything using Tags. I suppose you can save things in other ways that aren't so obvious.

埋情葬爱 2025-01-01 07:57:30

datagridview 有两种保存数据的选项。
首先使用序列化类
第二个使用数据表。
第二种解决方案:
以文本形式序列化数据表并将其保存到演示文稿或幻灯片标签中。

public static string TableToString(this DataTable data)
    {
        string xmlString = string.Empty;
        using (TextWriter writer = new StringWriter())
        {
            data.WriteXml(writer,XmlWriteMode.WriteSchema );
            xmlString = writer.ToString();
        }
        return xmlString;
    }

There are two option to save data of datagridview.
First using serialize class
second using Datatable.
Second solution:
Serialize your datatable in text and save it into presentation or slide tag.

public static string TableToString(this DataTable data)
    {
        string xmlString = string.Empty;
        using (TextWriter writer = new StringWriter())
        {
            data.WriteXml(writer,XmlWriteMode.WriteSchema );
            xmlString = writer.ToString();
        }
        return xmlString;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文