从DataTable生成Excel文件 [英] generate Excel FIle From DataTable

查看:214
本文介绍了从DataTable生成Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam在网站上工作
我的数据表包含一些日期和值
我需要的是将这些数据表转换为具有某些导入点的excel文件

1-使某些列不可见
2-更改日期和值列的格式
在更改日期后自动添加excel文件的3-add宏我知道宏语句,但我不知道从编码中添加它
4-i有一些包含公式的字段,例如sum(),count()等,我想为那些单元格添加这些公式,以便在excel值更改后再次生成值
5-我希望某些行的颜色取决于1列的值我有1个Coolumn调用的行颜色我希望从此读取的每一行的前景色是colum
6-我需要打开的excel文件没有保存在硬盘上,因为我在服务器上工作,所以如果保存不保存,将保存在服务器上而不是本地文件中,就像当您将redlc导出到excel时一样,他只是打开excel将文件保存在内存中,然后让您保存或关闭

**************
我知道我要求很多要求,但我需要帮助
&谢谢任何人在任何这些方面都能为我提供帮助.

iam working on web site
i have data table that contain some dates & Values
what i need is i need to convert this is data table to excel file wit some import points

1- make some columns invisible
2- change the format of dates & values columns
3-add macro for automic sorting excel file after change date i know the macro statement but i don''t know to add it from coding
4-i have some fields that contain formula like sum(),count() etc i want to add those formula for those cells to generate values again after changes in excel value
5-i want some rows to be in different colors depend on 1 column value i have 1 coolumn callled rowcolor i want the forground for each row read from this is colum
6- i need this is excel file to be opened not saved on hard disk becasue i work on server so if it save dit''ll be saved on server not on local the same like when u export redlc to excel he just open the excel file on memeory then let u to save or close

**************
i know i ask for many requirements but i need helps
& thanks for any body could help me in any of those points

推荐答案

6-我需要打开的excel文件没有保存在硬盘上,因为我在服务器上工作,所以如果保存不保存,将保存在服务器上,而不是保存在本地,就像当您将redlc导出到excel时一样,他只是打开内存中的excel文件,然后让您保存或关闭

您确实意识到,如果您打开Excel,它也将在服务器上而不是在客户端上打开,并且您无法强制从服务器在客户端上打开Excel?

我认为您在开始担心第1-5点之前需要重新考虑您的要求,因为如果第6点仍然无法正常工作,那么就没有必要将时间花在其他方面了……
6- i need this is excel file to be opened not saved on hard disk becasue i work on server so if it save dit''ll be saved on server not on local the same like when u export redlc to excel he just open the excel file on memeory then let u to save or close

You do realize that if you open Excel, it will also be opened on the Server, not the Client, and that there is no way you can force Excel to open on the client from the server?

I think you need to re-think your requirement before you start worrying about points 1-5, because if point 6 isn''t going to work anyway, then there is no point in spending your time on the others...


尝试一下.
将数据表导出为具有C#格式的Excel [ ^ ]

这可能无法回答您的所有观点,但是您仍然可以从中得出结论.
Try this.
Export DataTable to Excel with Formatting in C#[^]

This might not answer all your points, but still you can derive from this.


这篇关于从DataTable生成Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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