【 tulaoshi.com - ASP.NET 】
///
/// 将DataSet里所有数据导入Excel. /// 需要添加COM: Microsoft Excel Object Library. /// using Excel; /// ///
///
public static void ExportToExcel(string filePath, DataSet ds) { object oMissing = System.Reflection.Missing.Value; Excel.ApplicationClass xlApp = new Excel.ApplicationClass(); try { // 打开Excel文件。以下为Office 2000. Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(filePath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing); Excel.Worksheet xlWorksheet; // 循环所有DataTable for( int i=0; i
来源:http://www.tulaoshi.com/n/20160129/1487130.html