public static int ExportToExcel(DataSet ds, string filename)
{
int state = 0;
int tablecount = ds.Tables.Count;
if (tablecount <= 0) return 0;
int index = 0;
Excel.Application xlApp = null;
Excel.Workbook xlBook = null;
Excel.Worksheet xlSheet = null;
int rowIndex = 1;
int colIndex = 0;
object missing = Missing.Value;
List<System.Data.DataTable> listTable = new List<System.Data.DataTable>();