DataTable to Excel export
<p>I m developing a web project in asp.net 3.5</p>

<p>I want to export datatable to Excel. But there are 20.000 rows in datatable. Sometimes timeout problem happens..</p>

<pre><code> protected string Worksheet97_Header()
        {
            string s = "&lt;tr&gt;";
            foreach (ExcelColumn col in Columns)
            {
                s += "&lt;th&gt;" + col.Header_Text + "&lt;/th&gt;";
            }
            s+="&lt;/tr&gt;";
            return s;
        }
        protected string Worksheet97_Data()
        {
            string s = "";
            try
            {
                for (int i = 0; i &lt; data.Rows.Count; i++)
                {
                    s += "&lt;tr&gt;";
                    foreach (ExcelColumn col in Columns)
                    {
                        if (col.Column_Type == "System.String")
                            s += "&lt;td&gt;" + data.Rows[i][col.Field_Name].ToString() + "&lt;/td&gt;";
                        if (col.Column_Type == "System.DateTime")
                            s += "&lt;td&gt;" + Convert.ToDateTime(data.Rows[i][col.Field_Name]).ToString("dd.MM.yyyy HH:mm:ss") + "&lt;/td&gt;";
                        if (col.Column_Type == "System.Int32")
                            s += "&lt;td&gt;" + data.Rows[i][col.Field_Name].ToString() + "&lt;/td&gt;";
                        if ((col.Column_Type == "System.Double") |
                            (col.Column_Type == "System.Decimal") |
                            (col.Column_Type == "System.Int16") |
                            (col.Column_Type == "System.Int32") |
                            (col.Column_Type == "System.Int64"))

                            s += "&lt;td&gt;" + Convert.ToDouble(data.Rows[i][col.Field_Name]).ToString("0.00") + "&lt;/td&gt;";
                    }
                }
            }
            catch (Exception ex)
            {
                string a = ex.ToString();            

            }

            return s;
        }

        public string Export_Excel97()
        {
            string s = "";
            s = "&lt;table border=\"1\"&gt;";
            s += Worksheet97_Header();
            s += Worksheet97_Data();
            s += "&lt;/table&gt;";
            return s;
        }
</code></pre>

<p>Thanks.</p>
