简体   繁体   English

用C#从DataTable编写Excel工作表

[英]Write excel sheet from DataTable in c#

如何在C#中编写具有两个字段的Excel工作表(让它们成为DataTable的f1,f2)?

You can use the OleDb components to achieve this using SQL. 您可以使用OleDb组件通过SQL来实现此目的。 A sample is given in this question . 这个问题给出了一个例子。

Please note that to use this with Excel 2003 files, your program must be compiled X86 only, as the JET driver is available for 32-bit only. 请注意,要将此功能与Excel 2003文件一起使用,您的程序必须仅编译为X86,因为JET驱动程序仅适用于32位。

To write Excel 2007/10 files, you need to use a different JET driver ( see here ). 要编写Excel 2007/10文件,您需要使用其他JET驱动程序( 请参见此处 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM