try
            {
                StreamWriter sw = new StreamWriter(Server.MapPath("Public/DataExport/Data.xls"), false, System.Text.Encoding.GetEncoding(-0));
                string str = "";
                Array array = null;
                for (int i = 0; i < arraylist.Count; i++)
                {
                    str = "";
                    array = ((Array)arraylist[i]);
                    for (int k = 0; k < array.Length; k++)
                    {
                        str += "\t" + (array.GetValue(k) == null ? "" : array.GetValue(k).ToString());
                    }
                    sw.WriteLine(str);
                }
                sw.Close();
                return "xls";
            }
            catch
            {
                return "false";
            }

导出后打开该Excel会发现它并非标准的Excel文件,而是文本文件(制表符)方式分隔的txt文件;当我们再把此文件转换成dataset的时候就出现了问题,它需要我们手动的把文件另存为xls

posted on 2009-03-13 09:49  游子  阅读(1721)  评论(0编辑  收藏  举报