Это мой код:
Код: Выделить всё
public void ExportToExcel(string name, DataTable dt)
{
lock (this)
{
System.Text.StringBuilder tmp = new System.Text.StringBuilder(1000000);
for (int i = 0; i < rt.Columns.Count; i++)
{
string colname = rt.Columns[i].ColumnName;
if (i < rt.Columns.Count - 1)
{
tmp.Append(colname + "\t");
}
else
{
tmp.Append(colname + "\t\r\n");
}
}
foreach (DataRow r in rt.Rows)
{
for (int i = 0; i < r.ItemArray.Length; i++)
{
if (i < r.ItemArray.Length - 1)
{
tmp.Append((r.ItemArray.GetValue(i)) + "\t");
}
else
{
string status = r.ItemArray.GetValue(i).ToString();
int indexS = status.IndexOf(">", 0);
int indexE = 0;
string subStatus = "";
if (indexS > 0)
{
indexE = status.IndexOf("