从datatable生成Excel,然后使用.net将其放入Outlook Mail [英] Generation of Excel from datatable and then putting it in Outlook Mail using .net

查看:71
本文介绍了从datatable生成Excel,然后使用.net将其放入Outlook Mail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我实际上正在创建一个C#windows应用程序,它将从数据表生成一个Excel,这是查询的输出。 excel需要格式化每个列和标题的一些特定字体..我知道如何创建excel但是如何格式化我不知道。在创建excel之后,任何人都可以提供帮助。



我需要获取文件并选择一些特定列,然后将它们粘贴到Outlook邮件中并发送它。 ..有可能??



任何指针都会有帮助...谢谢........

Hi,

I am actually creating a C# windows app that will be generating an excel from a data-table which is the output of a query. The excel needs to be formatted with some specific fonts for each column and the headers.. I know how to create excel but how to format it is not known to me. Can anyone help.

after the excel is created, i need to fetch the file and select some particular columns and then paste them in an outlook mail and send it....is is possible??

ANY POINTERS WOULD BE HELPFUL...THANKS........

推荐答案

我过去做过这种事情的方式是使用自动化。



这类程序:

The way I have done this sort of things in the past was by using Automation.

This sort of programs:
//Start Excel and get Application object.
    oXL = new Excel.Application();
    oXL.Visible = true;

    //Get a new workbook.
    oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
    oSheet = (Excel._Worksheet)oWB.ActiveSheet;

    //Add table headers going cell by cell.
    oSheet.Cells[1, 1] = "First Name";
    oSheet.Cells[1, 2] = "Last Name";
    oSheet.Cells[1, 3] = "Full Name";
    oSheet.Cells[1, 4] = "Salary";







这很容易用Word生成这种代码。

一般我使用记录宏然后查看它生成代码的代码。

我假设你也许也可以和EXcel一样。



更多细节:

http://support.microsoft.com/kb/302084 [ ^ ]


这篇关于从datatable生成Excel,然后使用.net将其放入Outlook Mail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆