发布网友 发布时间:2022-04-10 02:54
共2个回答
热心网友 时间:2022-04-10 04:23
就是写文件啊,循环list string str = Guid.NewGuid().ToString(); string strPath = "C:\\Program Files\\" + str + ".xls"; FileStream fs = File.Create(strPath); StreamWriter sw = new StreamWriter(fs, Encoding.Unicode); string strLine = ""; // 写入列标题 for (int i = 0; i < colNames.Length; i++) { string[] col = colNames[i].Split('='); strLine = strLine + col[1].ToString() + Convert.ToChar(9); } sw.WriteLine(strLine); strLine = ""; // 写入报表数据 for (int i = 0; i < dt.Rows.Count; i++) { // for (int j = 0; j < colNames.Length; j++) { string[] col = colNames[j].Split('='); strLine = strLine + dt.Rows[i][col[0]].ToString() + Convert.ToChar(9); } sw.WriteLine(strLine); strLine = ""; } sw.Close(); fs.Close();热心网友 时间:2022-04-10 05:41
连接数据库,写SQL或DataSet,保存